Official ZPE/YASS documentationString data type
The String data type is one of the most commonly used data types within ZPE/YASS. String data types contain character sequences stored in a single array. As such, a string can have many operations similar to a list carried out on it. A string data type in ZPE is surrounded by quotation marks.
Examples of values that the String data type could contain include
As a reference type
As of version 1.8.12, strings are handled very differently and act as reference
types. This means several things for the string. This first is that using the
character index (e.g.
$v) and setting a value will change any references
to the string. As well as this, using reference functions (also added in version 1.8.12)
such as a
cut on a string will change the original value of the string
across the whole program.
Reference functions (ZPE 1.8.12+)
The String data type provides several reference functions that allow for ease of use:
$str1 = "Hello world" //Using TYPO (version 1.9.7+) declare str2 as string = "Hello world"
- get (number pos) ⇒ string
Returns a character from a position in a string.
- append (string str) ⇒ string
Appends a string to the current string
- prepend (string str) ⇒ string
Prepends a string to the current string
- cut (number start, number end) ⇒ string
Returns a substring from start to end and removes it from the string.
- length () ⇒ number
Returns the length of the string.