Jamie Balfour

Welcome to my personal website.

Find out more about me, my personal projects, reviews, courses and much more here.

Official ZPE/YASS documentationString data type

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

Escape sequences in YASS

YASS has supported escape sequences for some time. Escape sequences allow you to include quote marks within a string without having to use other methods such as inline documents or performing splits or substrings.

print("Hello \"World\"")

This will print:

Hello "World"

Unescaped strings (ZPE 1.12.7+)

Some times it may be necessary to avoid escaping in a string literal. This might be if you need to write something such as a Windows file path which utilise the \ symbol. ZPE 1.12.7 (July 2024, Loch Lion) introduced unescaping string literals. To do this, prepend the string literal with a @ sign:

print(@"C:\Program Files\ZPE\")

If the string wasn't escaped in the above, the parser would take the slash at the end as being an escape slash and would try to escape the quote mark.

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[0]) 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.

Feedback 👍
Comments are sent via email to me.