Navigation: thinBasic Modules > Core > Pointers > POKE$ |
|
Description
Store a sequence of bytes at a specified memory location.
Syntax
s = POKE$(Address, StringExpression)
s = POKE$(ASCIIZ, Address, StringExpression)
s = POKE$(STRING, Address, StringExpression)
Returns
String, the passed string expression
Parameters
Name |
Type |
Optional |
Meaning |
ASCIIZ |
Command |
Yes |
If ASCIIZ is specified, POKE$ writes successive characters to a target address in memory until a terminating $NUL byte is found in the source string. If no $NUL is found in the string, one is automatically appended to the target buffer. |
STRING |
Command |
Yes |
If STRING is specified, address is interpreted as a 32 bit placeholder for a dynamic string. This form allow handling dynamic strings inside UDT or using whatever 32 bit number. |
Address |
Numeric |
No |
A valid 32-bit memory address specifying the location in memory where starting to store data |
StringExpression |
String |
No |
A string expression that specifies the sequence of bytes to be stored in memory starting at the byte referenced by address |
Remarks
POKE$ stores a string in consecutive bytes where the ASCII code of the first character of the string is stored in the first byte of memory, the next ASCII code is stored in the next byte of memory, and so on, until all bytes in StringExpression are stored. It is the programmer’s responsibility to ensure that POKE$ does not overrun the target memory area to avoid data corruption or protection faults.
Restrictions
See also
STRPTR, VARPTR, POKE$, POKE, PEEK$, PEEK
Examples
'---Example using STRING for to handle dynamic strings inside UDT structures.
Type MyType
Name As Long
ID As Long
Notes As Long
End Type
Dim MyUSer As MyType
POKE$ String, VARPTR(MyUSer.Name) , "MyName"
POKE$ String, VARPTR(MyUSer.ID) , "MyID"
POKE$ String, VARPTR(MyUSer.Notes), "Whatever string or data or binary sequence are allowed"
MSGBOX 0, _
"[" & PEEK$(String, VARPTR(MyUser.Name) ) & "]" & $crlf & _
"[" & PEEK$(String, VARPTR(MyUser.ID) ) & "]" & $crlf & _
"[" & PEEK$(String, VARPTR(MyUser.Notes)) & "]" & $crlf & _
© 2004-2008 thinBasic. All rights reserved. | Version 1.7.0.0 | Web Site: http://www.thinbasic.com |