QB64.com

QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.

The _MEM function returns a _MEM block referring to the largest possible continuous memory region beginning at a variable’s offset.

Syntax

memoryBlock = _MEM(referenceVariable)

Unsecure syntax

memoryBlock = _MEM(offset, byteSize)

Parameter(s)

Description

Example(s)

Assigning values to reference variables in memory.


DIM SHARED m(3) AS _MEM
DIM SHARED Saved(3)

m(1) = _MEM(x)
m(2) = _MEM(y)
m(3) = _MEM(z)

x = 3: y = 5: z = 8
PRINT x, y, z
Save x, y, z
x = 30: y = 50: z = 80
PRINT x, y, z

RestoreIt
PRINT x, y, z

_MEMFREE m(1)
_MEMFREE m(2)
_MEMFREE m(3)
END

SUB Save (n1, n2, n3)
Saved(1) = n1
Saved(2) = n2
Saved(3) = n3
END SUB

SUB RestoreIt
_MEMPUT m(1), m(1).OFFSET, Saved(1)
_MEMPUT m(2), m(2).OFFSET, Saved(2)
_MEMPUT m(3), m(3).OFFSET, Saved(3)
END SUB 

See Also