GOLF(2gg)

NAME
new-string - (strings)

PURPOSE
Create a new string.

SYNTAX

        new-string <variable> length <length>

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".

SEE ALSO
 Strings

concatenate-strings copy-string count-substring delete-string lower-string new-string read-split replace-string set-string split-string string-length trim-string upper-string write-string See all documentation