Usage
Writes a value of type Integer or Unsigned to memory. Not available in WinTask Lite.
Syntax
PokeInteger(<address>, <value>, <number_of_bytes>)
or
ret = PokeInteger(<address>, <value>, <number_of_bytes>)
Parameters
<address>
: integer or UNSIGNED, address to which<value>
is written.<number_of_bytes>
: 1, 2, or 4.
Return value
ret
: numeric return code. When <value>
has been written successfully, the function returns 0, otherwise use this return code for Error Handling.
Example
dim Myvalue as unsigned
Myvalue = 32500
ret = PokeInteger(MemPtr, Myvalue, 4)
Example Code
' ASCII code
' 77 121 32 115 116 114 105 110 103
' M y s t r i n g
dim pointer as unsigned
dim address as unsigned
' Writes a string to memory
pointer = allocate(32)
ret = PokeString(pointer, "My string", 1)
' Reads the string as integers (ASCII codes)
i = 0
repeat
address = pointer + i
var = PeekInteger(address, 1)
mes$ = mes$ + "Byte " + str$(1 + i) + " : " + str$(var) + "\n\"
i = i + 1
until i = 8
msgbox(mes$, 64, "Reads in memory")
'---------------------------------------------------------------
' Writes integer in memory (ASCII codes)
pointer = allocate(32)
address = pointer
ret = PokeInteger(pointer, 77, 1)
pointer = pointer + 1
ret = PokeInteger(pointer, 121, 1)
pointer = pointer + 1
ret = PokeInteger(pointer, 32, 1)
pointer = pointer + 1
ret = PokeInteger(pointer, 115, 1)
pointer = pointer + 1
ret = PokeInteger(pointer, 116, 1)
pointer = pointer + 1
ret = PokeInteger(pointer, 114, 1)
pointer = pointer + 1
ret = PokeInteger(pointer, 105, 1)
pointer = pointer + 1
ret = PokeInteger(pointer, 110, 1)
pointer = pointer + 1
ret = PokeInteger(pointer, 103, 1)
' 0 binary for end of string
pointer = pointer + 1
ret = PokeInteger(pointer, 0, 1)
var$ = PeekString$(address)
msgbox("String read: " + var$, 64, "Memory read")