GLBasic User Manual

Main sections

BYREF

FUNCTION f: BYREF arg#$



With the modifier "BYREF" you can pass a variable by reference. Normally when calling a function a copy is taken of any variable passed to the function and the function uses the copy. By using the BYREF command you can change the actual value of the passed variable itself from within the function.
Arrays will always be passed by reference so using BYREF for an array argument is unnecessary.

This keyword is for advanced users only.

LOCAL b$
b$ = "XY"
foo(b$)

// print "test"
PRINT b$, 0,0
SHOWSCREEN
MOUSEWAIT

FUNCTION foo: BYREF a$
    a$ = "test"
ENDFUNCTION

See also...