Futurebasic/Language/Reference/varptr

VARPTR edit

Syntax edit

address& = VARPTR({var|FN userFunction})
address& = @var

Description edit

VARPTR(var) returns the memory address where the first byte of the variable var is located. You can use this value as a "pointer" to var. If var is a local variable inside a local function, the value returned by VARPTR(var) may be different each time you execute the function, and is not valid after the function exits. The syntax @var is just a shorthand version of VARPTR(var).

VARPTR(FN userFunction) is identical to the @FN userFunction function.

Example edit

You cannot use VARPTR(var) with variables that use register storage, because such variables do not have addresses. See the DIM statement and the REGISTER ON/OFF statements to learn how to prevent a variable from using register storage.

Because the "@" symbol has a special meaning when it appears after the PRINT or LPRINT keyword, you cannot use the @var syntax as the first item in a list of print items.

PRINT @myVar#<spacer type="horizontal" size="15">'This does not work<br> ("@" is misinterpreted)
PRINT (@myVar#)<spacer type="horizontal" size="144">'This works.
PRINT VARPTR(myVar#)<spacer type="horizontal" size="108">'This works too.

See Also edit

@FN; REGISTER ON/OFF; PRINT; LPRINT; PEEK; POKE; BLOCKMOVE; DIM