1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
.TH GOLF 2gg $VERSION $DATE Development Tools
.SH NAME
new-string \- (strings)
.SH PURPOSE
Create a new string.
.SH SYNTAX
.RS 4
.EX
new-string <variable> length <length>
.EE
.RE
.SH 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.
.SH EXAMPLES
Create new string and alter it:
.RS 4
.EX
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
.EE
.RE
The output of above code would be "AB".
.SH SEE ALSO
Strings
\fBconcatenate-strings\fP
\fBcopy-string\fP
\fBcount-substring\fP
\fBdelete-string\fP
\fBlower-string\fP
\fBnew-string\fP
\fBread-split\fP
\fBreplace-string\fP
\fBset-string\fP
\fBsplit-string\fP
\fBstring-length\fP
\fBtrim-string\fP
\fBupper-string\fP
\fBwrite-string\fP
See all
\fBdocumentation\fP
|