Skip to content

Strings

Matěj Štágl edited this page Dec 1, 2018 · 13 revisions

Text in SGML is stored as a sequence of characters, commonly referred to as a string. Characters within this sequence are of type char and can be accessed using array literals. Strings are always defined within double quotation marks, while single character is defined within apostrophes.

string myString = "Hello World!";
char sequenceElement = myString[1]; //e
char anotherChar = 'A';

Strings are immutable, meaning that unless a value is assigned to a string its value will never change.

string myString = "Simplex engine";
string_replace(myString, " engine", ""); // takes myString, looks for " engine" and removes is
show_message_debug(myString); // Still returns "Simplex engine"

myString = string_replace(myString, "engine", ""); // myString is now just "Simplex"

Strings may contain special (escape) sequences to force behavior on demand. Escape sequences are defined as \x where x is represented by one or more characters.

  • \n - Insert line feed (newer line break)
  • \t - Insert tab
  • \r - Insert carriage return (line break on older systems)
  • \' - Insert single quote
  • \" - Insert double quote
  • \\ - Insert backslash

If you'd prefer to omit this functionality, prepend your string with @.

string myString = @"\folder\subfolder\file.txt";

Any font unsupported characters within a string will be replaced with a symbol. Easiest way to troubleshoot this is to increase glyph range of your font to include characters you are in need of.

String Functions

Other functions can check what keyboard input has been pressed. These functions are as follows:

Back to Manual

Clone this wiki locally