From QB64 Wiki
Revision as of 23:35, 21 April 2012 by imported>Clippy
Jump to navigation Jump to search

The _MEMNEW function allocates new memory and returns a _MEM memory block referring to it.


memory_block = _MEMNEW(byte_size%%)

  • The memory block value created holds the starting OFFSET, SIZE, TYPE and ELEMENTSIZE.
  • The byte size parameter is the desired byte size of the memory block.
  • All values created by this function MUST be freed using _MEMFREE!
  • If the read only memory block.SIZE is 0, the memory block was not created!


DIM m AS _MEM DIM f AS STRING * 5 m = _MEMNEW(5) 'create new memory block of 5 bytes a = 12345 _MEMPUT m, m.OFFSET, a _MEMGET m, m.OFFSET, b PRINT b c$ = "Doggy" _MEMPUT m, m.OFFSET, c$ _MEMGET m, m.OFFSET, d$ _MEMGET m, m.OFFSET, f e$ = _MEMGET(m, m.OFFSET, STRING * 5) PRINT "d$ = ";d$ PRINT "e$ = ";e$ PRINT "f = ";

See also:

Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page