new-string - (strings)
Contents
Description
New empty string <variable> of length <length> is allocated. The <variable> is an empty string (i.e. ""),
however <length> bytes are allocated.
new-string is useful when you need to create a block of memory of certain length, and then change its
individual bytes (such as with set-string).
Note that if <length> is a numeric literal, then <variable> will be allocated on the stack if <length> is
lesser than 1024 bytes; this makes such strings faster at run time, especially for server processes. In
all other cases, <variable> is dynamically allocated from the heap.
Also note that <variable> (like all strings, text, binary and however allocated) has an implicit null
byte placed after <length> bytes.
Examples
Create new string and alter it:
new-string my_string length 30
set-string my_string[0] = 'A'
set-string my_string[1] = 'B'
set-string my_string[2] = 0
print-out my_string new-line
The output of above code would be "AB".
Name
new-string - (strings)
Purpose
Create a new string.
See Also
Strings
concatenate-stringscopy-stringcount-substringdelete-stringlower-stringnew-stringread-splitreplace-stringset-stringsplit-stringstring-lengthtrim-stringupper-stringwrite-string See all documentation
$DATE $VERSION GOLF(2gg)
Syntax
new-string <variable> length <length>
