Difference between revisions of "MEMNEW"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
imported>Clippy
m
Line 8: Line 8:
 
* The ''memory block'' value created holds the starting OFFSET, SIZE, TYPE and ELEMENTSIZE.  
 
* 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.
 
* 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!'''
 
* '''If the read only memory block.SIZE is 0, the memory block was not created!'''
  

Revision as of 23:35, 21 April 2012

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


Syntax

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!


Example:

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:



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