From QB64 Wiki
Revision as of 17:29, 20 August 2012 by imported>Clippy
Jump to navigation Jump to search

The _MEMELEMENT function returns a _MEM block referring to a variable's memory ,but not past it.


memory_block = _MEMELEMENT(reference_variable)

  • The reference variable parameter designates the existing variable name using the memory block.
  • _MEMELEMENT is the same as _MEM but in an array it returns the specifications of an element, not the entire array.
  • All values created by memory functions MUST be freed using _MEMFREE with a valid _MEM variable type.

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

DIM a(1 TO 100) AS _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

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.
  • _MEM value returns the array .SIZE as 51 bytes from the first array index .OFFSET.
  • _MEMELEMENT value returns the array element .SIZE as one byte.

See also:

Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page