Can someone explain the usage of VAR to me?

BlitzMax Forums/BlitzMax Programming/Can someone explain the usage of VAR to me?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

@AngelDaniel:
Thanks for the explanation A.D., but in my post you'll see that I already knew that... (I just was mainly wondering why Var came before in some instances, and after in other instances).

"I guess you are allowed to put the Var before or after the pointer name."
Actually, I thought this, too (and that would be fine with me), but you will get a sytax error if you reverse the order in either of the two code examples above.

This type of parameter passing is sometimes called 'By Reference' (ByRef) or 'By Address' (which is what it really is).

Anyway, the two uses of Var are not actually doing the same thing:
The first one is saying 'use the address of the passed variable...'
And the second example is saying 'Use the value *AT* the address (p is declared as a pointer, remember).

Maybe two different keywords should have been used, instead of placing the keyword before or after for the different uses?

Russell

@A.D.
"I just thought it means `variable"
I think it stands for VARy hard to understand ;)