Expand/Shrink

poke_string

Definition: atom addr = poke_string(atom buffaddr, integer buffsize, sequence s)
-- or --
atom addr = poke_wstring(atom buffaddr, integer buffsize, sequence s)
Description: Stores a C-style null-terminated ANSI or utf8 string, or a 16-bit WideString in memory.

buffaddr: the RAM address to store the string at.
buffsize: the number of bytes available, starting from buffaddr.
s: the string to store at address buffaddr.

Returns an atom. If this is zero, then nothing was stored, otherwise it is the address of the terminating zero after the stored string.
pwa/p2js: Not supported.
Comments: This does not allocate RAM. You must supply the preallocated area (or use allocate_string or allocate_wstring instead).
Use poke_string() for ANSI and utf8 strings, and poke_wstring() for 16-bit WideStrings.
If s is not a string, or more specifically any element of s is not an atom, or it is longer than the available space, then nothing is stored and a zero is returned.
Example:
atom title = allocate(20)
if poke_string(title, 20, "The Wizard of Oz") then
    -- successful
else
    -- failed
end if
...
free(title)
Implementation: See builtins\pokestr.ew (an autoinclude) for details of the actual implementation.
See Also: allocate, allocate_string, allocate_wstring, free