1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-06-29 11:40:38 +00:00
QB64-PE/internal/help/_MEMGET_(function).txt
SteveMcNeill 33adc04fc4 Add temp folder to repo. It's necessary as well!
Just more initial setting on... nothing much to see here.
2022-04-28 13:39:56 -04:00

47 lines
2.3 KiB
Plaintext

{{DISPLAYTITLE:_MEMGET (function)}}
The [[_MEMGET]] function returns a value from a specific memory block name at the specified OFFSET using a certain variable type.
{{PageSyntax}}
: {{Parameter|returnValue}} = [[_MEMGET]]({{Parameter|memoryBlock}}, {{Parameter|bytePosition}}, {{Parameter|variableType}})
{{Parameters}}
* Returns a value of the {{Parameter|variableType}} designated. The holding variable must match that [[TYPE]].
* {{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|variableType}} is a variable [[TYPE]] like [[_BYTE]], [[INTEGER]], [[SINGLE]], [[DOUBLE]], etc.
{{PageDescription}}
* {{Parameter|memoryBlock}}.[[OFFSET]] returns the starting byte position of the block. Add bytes to move into the block.
* 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.
* [[STRING]] values should be of a defined length. Variable length strings can actually move around in memory and not be found.
* '''_MEMGET variable values that are assigned a variable [[type]] other than a memory type do not need to be freed.'''
{{PageExamples}}
''Example:'' [[DEF SEG]] and [[VARPTR]] are no longer necessary to do things in memory just like [[POKE]] and [[PEEK]] do.
{{CodeStart}} '' ''
{{Cl|DIM}} o {{Cl|AS}} {{Cl|_MEM}}
o = {{Cl|_MEM (function)|_MEM}}(d&) 'OLD... o% = VARPTR(d&)
{{Cl|_MEMPUT}} o, o.OFFSET + 1, 3 {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|_BYTE}} 'a POKE
v = {{Cl|_MEMGET (function)|_MEMGET}}(o, o.OFFSET + 1, {{Cl|_UNSIGNED}} {{Cl|_BYTE}}) 'a PEEK
{{Cl|PRINT}} v 'prints 3
{{Cl|PRINT}} d& 'prints 768 because the 2nd byte of d& has been set to 3 or 3 * 256
{{Cl|_MEMFREE}} o
{{CodeEnd}}
:''Explanation:'' The memory block and OFFSET are given by [[_MEMPUT]] and the _MEMGET function, with the designated type.
{{PageSeeAlso}}
* [[_MEM]], [[MEM (function)]]
* [[_MEMGET]], [[_MEMPUT]]
* [[_MEMNEW]], [[_MEMFILL]]
* [[_MEMCOPY]]
{{PageNavigation}}
<