Home > Language Reference > System Functions > PokeString

PokeString

The PokeString function writes a value of type String to memory.

Syntax

ret = PokeString(<address>, <text> [, 0|1|2 [, Unicode]])

Parameters

<address>. unsigned variable only, address where to write. The unsigned variable must be declared at the beginning of the script using Dim function.

<text>, string, text to write in the memory.

0|1|2, optional integer, constant indicating the end of string character. 0: no character is added, 1: a binary zero is added (default value), 2: two binary zeroes are added.

Unicode
. optional keyword. If specified, Unicode encoding is used for the return value.

Return value

ret, optional integer return value. If the value is successfully written, the return value is 0. If the function fails, the return value is a nonzero value (see System Functions Error Codes).

See also

PeekString$
PokeInteger
PeekInteger

Examples

dim Memptr as unsigned
Memptr=32500
ret=PokeString(MemPtr,"My string",1)


'Script returning the Windows installation folder
'Memory address
dim pointer as unsigned
'Memory allocation
pointer=allocate(64)
'Prepare a variable for the return value
wdir$=" "
'Write the blank string to memory
ret=PokeString(pointer,wdir$,0)
'In Win32, an A must be added to functions returning an ASCII string
a=External("kernel32","GetWindowsDirectoryA",pointer,64)
'Read the string at the given memory address
var$=peekString$(pointer)
msgbox(var$)