how can I to pass a paramter by reference?
Monkey Forums/Monkey Programming/how can I to pass a paramter by reference?
| ||
That's the questio, how does one pass a paramter by reference, on a function declaration? |
| ||
You can fudge it by passing in an array and modifying the contents.Function Main:Int() Local arr:Int[1] Test(arr) Print arr[0] Return 0 End Function Test:Void(someParam:Int[]) someParam[0] = 5 End |
| ||
well, my scenario is, I'm writing a default general purpose function that gets a string representation of an HEX number, and returns the interget value of the number AND a bool that determines wether it the conversion was properly done or not. So I can't really use an array as they're different types and using an object just to be able to make a funciton call seems a bit overkill, dunno... Isn't there any var or byref or * or anything to pass a variable by reference? |
| ||
Isn't there any var or byref or * or anything to pass a variable by reference? No. Use an object, or use Poke() and Peek() in the new Data Buffer module. An object would be faster. |