VAR
BlitzMax Forums/BlitzMax Beginners Area/VAR| 
 | ||
| What is the true purpose in this Command and how can it help me to write better code. | 
| 
 | ||
| You can use it to pass variables by-reference (and return multiple values from functions). 
Function Foobar( a Var, b Var, c Var )
    a = SomethingMeaningful
    b = SomethingAlsoMeaningful
    c = AYourMomJoke
End Function
 | 
| 
 | ||
| Here's another example (with a call to the function using the by-reverence variables): Graphics 640, 480, 16, -1 Function GetMouseCoords(xToSet var, yToSet var) xToSet = MouseX() yToSet = MouseY() End Function Local myX, myY myX = 0 myY = 0 Print myX + ", " + myY ' output will be "0, 0" MoveMouse(200, 400) GetMouseCoords(myX, myY) Print myX + ", " + myY ' output will be "200, 400" because myX and myY were passed by reference | 
| 
 | ||
|  using the by-reverence variables  Haaaaaaaaaahahahahahahahaha. Oh, that was a good laugh... | 
| 
 | ||
| Heh. Fery vunny. (Now bown down to the variable!) | 
| 
 | ||
| It can also be used to get the contents of a ptr to a variable. An example is given for the ptr keyword. | 
| 
 | ||
| ...what can var ptr be used for? | 
| 
 | ||
| varptr gets the pointer of a variable. | 
| 
 | ||
| Yep, but what can you do with that information? | 
| 
 | ||
| I think some API functions need ptr to variable. |