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 _MEMELEMENT function returns a _MEM block referring to a variable’s memory, but not past it.

Syntax

memoryBlock = _MEMELEMENT(referenceVariable)

.TYPE values (version 1.000 and up)

Note: If a future integer, float or other type doesn’t have a size that is 1,2,4,8,16,32,64,128 or 256 it won’t have a size-bit set.

Versions prior to 1.000

Note: _MEM and _OFFSET values cannot be cast to other variable types.

Example(s)

Comparing the specifications returned by _MEM and _MEMELEMENT from an array.


DIM a(1 TO 100) AS _UNSIGNED _BYTE

DIM m1 AS _MEM
DIM m2 AS _MEM

m1 = _MEM(a(50)) 'function returns information about array up to specific element
PRINT m1.OFFSET, m1.SIZE, m1.TYPE, m1.ELEMENTSIZE

m2 = _MEMELEMENT(a(50)) 'function returns information about the specific element
PRINT m2.OFFSET, m2.SIZE, m2.TYPE, m2.ELEMENTSIZE

END 

Output using VERSION .954 ONLY .TYPE values: 1 (integer) + 2 (unsigned)


28377205        51        3        1
28377205        1         3        1 

Explanation: _MEM returns the info about the array to that element while _MEMELEMENT returns info about that element only.

See Also