2016-03-18 11:36:04 +00:00
|
|
|
{{DISPLAYTITLE:_MEMGET}}
|
2017-10-10 14:55:21 +00:00
|
|
|
The [[_MEMGET]] statement reads a portion of a memory block at an OFFSET position into a variable, array or user defined type.
|
2015-08-02 12:12:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
{{PageSyntax}}
|
2017-10-10 14:55:21 +00:00
|
|
|
: [[_MEMGET]] {{Parameter|memoryBlock}}, {{Parameter|bytePosition}}, {{Parameter|destinationVariable}}
|
2015-08-02 12:12:44 +00:00
|
|
|
|
|
|
|
|
2017-10-10 14:55:21 +00:00
|
|
|
* {{Parameter|memoryBlock}} is a [[_MEM]] variable type memory block name created by [[_MEMNEW]] or the [[_MEM (function)|_MEM]] function.
|
|
|
|
* {{Parameter|bytePosition}} is the {{Parameter|memoryBlock}}.[[OFFSET]] memory start position plus any bytes to move into the block.
|
|
|
|
* {{Parameter|destinationVariable}} is the variable assigned to hold the data. The number of bytes read is determined by the variable [[type]] used.
|
2016-03-18 11:36:04 +00:00
|
|
|
|
|
|
|
|
2017-10-10 14:55:21 +00:00
|
|
|
{{PageDescription}}
|
|
|
|
* The [[_MEMGET]] statement is similar to the [[GET]] statement used in files, but the position is required.
|
2016-03-18 11:36:04 +00:00
|
|
|
* The memory block name.[[OFFSET]] returns the starting byte position of the block. Add bytes to move into the block.
|
2017-10-10 14:55:21 +00:00
|
|
|
* The variable type held in the memory block can determine the next {{Parameter|bytePosition}} to read.
|
|
|
|
* [[LEN]] can be used to determine the byte size of numerical or user defined variable [[type]]s regardless of the value held.
|
2016-03-18 11:36:04 +00:00
|
|
|
* [[STRING]] values should be of a defined length. Variable length strings can actually move around in memory and not be found.
|
2015-08-02 12:12:44 +00:00
|
|
|
|
|
|
|
|
2017-10-10 14:55:21 +00:00
|
|
|
{{PageExamples]]
|
2015-08-02 12:12:44 +00:00
|
|
|
''Example:'' Shows how to read the PSET color values from a program's [[SCREEN]] memory to an array.
|
|
|
|
{{CodeStart}} '' ''
|
|
|
|
{{Cl|SCREEN}} 13
|
|
|
|
{{Cl|PSET}} (0, 0), 123
|
|
|
|
{{Cl|PSET}} (1, 0), 222 'create screen image
|
|
|
|
|
|
|
|
'here is an array
|
|
|
|
{{Cl|DIM}} screen_array(319, 199) {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|_BYTE}} 'use screen dimensions from 0
|
|
|
|
|
|
|
|
'here's how we can copy the screen to our array
|
|
|
|
{{Cl|DIM}} m {{Cl|AS}} {{Cl|_MEM}}
|
|
|
|
m = {{Cl|_MEMIMAGE}} '0 or no handle necessary when accessing the current program screen
|
|
|
|
{{Cl|_MEMGET}} m, m.OFFSET, screen_array()
|
|
|
|
|
|
|
|
'here's the proof
|
|
|
|
{{Cl|PRINT}} screen_array(0, 0) 'print 123
|
|
|
|
{{Cl|PRINT}} screen_array(1, 0) 'print 222
|
|
|
|
{{Cl|END}} '' ''
|
|
|
|
{{CodeEnd}}
|
|
|
|
|
|
|
|
|
2017-10-10 14:55:21 +00:00
|
|
|
{{PageSeeAlso}}
|
2015-08-02 12:12:44 +00:00
|
|
|
* [[_MEMGET (function)]]
|
|
|
|
* [[_MEMPUT]]
|
|
|
|
* [[_MEM]]
|
|
|
|
* [[_MEMIMAGE]]
|
|
|
|
* [[_MEMFREE]]
|
|
|
|
|
|
|
|
|
2019-04-15 01:15:33 +00:00
|
|
|
{{PageNavigation}}
|