GOLF(2gg)
π GOLF(2gg) π
okay bestie, welcome to the GOLF(2gg) manual page, Development section, and today's main character is set-string π
buckle up.
πΈ NAME πΈ
set-string β (strings)
π PURPOSE π
Set the value of a string variable. that's it, that's the whole job, and it eats every time β¨
β¨ SYNTAX β¨
set-string <variable> [ unquoted ] [ process-scope ] [ = <string> ]
set-string <variable> [ <index> ] = <number>
set-string <variable> length <length>
π¦ DESCRIPTION π¦
So here's the tea, bestie π β your string variable <variable> gets assigned the value of <string> if the = clause is hanging out there. if it's not there? then <variable> just gets handed an empty string. simple as that, no cap.
If you bring the process-scope clause, then <variable> becomes a process scope variable β meaning its value persists from one request to another for the entire life of the process π. but listen: this clause can only be used if <variable> didn't already exist. it's a first-come-first-served kind of situation, lowkey.
If you use the length clause, then the length of string <variable> gets set to <length>. and just like with literally every other string statement, you can only set the new length between zero and the current string length β that's the vibe check, no exceptions π. this is useful mostly when you're out here manipulating a string's individual bytes, and generally not in other cases (go peek at new-string for that).
If you use the unquoted clause, then the <string> literal is unquoted, and everything from the equal clause (=) to the rest of the line is the <string>. in that case you don't have to escape double quotes or backslashes at all, which is iconic honestly β¨. Note that in this case, unquoted and any other clause must appear prior to the equal clause (=) and after the variable, because otherwise they wouldn't be recognized. like, the parser simply will not see them, periodt. for instance:
set-string my_string unquoted = this is "some" string where there escape characters like \n do "not work"
This is the same as:
set-string my_string = "this is \"some\" string where there escape characters like \n do \"not work\""
The unquoted clause is your bestie when you're writing string literals that would otherwise need a ton of escaping π. You can use a double backslash at the end of the line to split the line with a new line in between:
set-string unq1 unquoted =This is one line\ second line and\ third!
The above will create a string:
This is one line
second line and
third!
A string can also be represented as a concatenation of string literals β this is super useful when you want to preserve spaces, for instance π:
set-string a="something is " \
" very good " \
" with spaces!! "
// string is "something is very good with spaces!! "
You can also use set-string to set a byte inside it π§. in this case, the <index> byte in the <variable> string is set to <number>. <index> starts with 0 for the first byte. For instance, the resulting "str" will be "Aome string" since 65 is the number representation of 'A':
set-string str = "some string"
set-string str[0] = 65
// or using a character constant as a number, to the same effect
set-string str[0] = 'A'
π¦ EXAMPLES π¦
Initialize "my_string" variable to "":
set-string my_string
Initialize "my_string" variable to "abc":
set-string my_string = "abc"
π₯ 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 π
and that's a wrap on GOLF(2gg), bestie π«Ά this page is version $VERSION, dated $DATE, and it absolutely served π
β¨
π¦ where this page comes from
- ubuntu questing: golf 601.4.41-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms