String expressions

Purpose: Add strings using a plus ("+") sign.

 <string> + <string> [ + ... ]

String variables and literals can produce a new string by concatenation, using plus ("+") clause.

Concatenation in this manner can be used in any statement where a string is expected.

Note that you can concatenate binary strings too, i.e. strings that do not end with a null character, with each binary string used in its true length. The result will in general be a binary string.
Subscription shortcut
You can reference string arrays and hash elements (see new-array and new-hash) by using subscription operator ([]), for instance:
 new-array sarr type string
 new-hash h
 write-array sarr key 0 value "some string"
 write-hash h key "one" value "uno"
 set-string str = sarr[0] + " another string" + h["one"]

Number to string shortcut
You can use "#" in front of a number expression to convert it to a string; see Shortcut in number-string.
Substrings within expressions
You can use "@" to extract a substring and use it as a <string> in additions; see copy-string.
Examples
For instance, here we'll concatenate two string constants and a variable "var":
 set-string var = "day"
 set-string newstr = "nice " + var + " it is!"
 print-out newstr new-line

The result will be "nice day it is!".

In the following case, directory (variable "dir") is concatenated with a forward slash ("/") and then file name (variable "file") to produce full path of a file to read:
 read-file dir+"/"+file to content



Copyright (c) 2019-2025 Gliim LLC. All contents on this web site is "AS IS" without warranties or guarantees of any kind.