Strings
Strings are a plain sequence of alphanumerical characters -
letters, numbers or symbols - which can be used for messages, onscreen menus
or the like.
They are defined this way:
STRING* name = "characters";
Defines a
global string pointer with the given name and initializes it to the content characters between
double quotation marks. If the character content is spread
over several lines, line feeds are automatically inserted.
LC Note
that in lite-C pointers are generally defined with a '*', so the green * is
required for lite-C, but must be omitted in C-Script.
Remarks:
-
The string alone, once defined, is not yet visible at the screen. To make
it visible, use a TEXT object. Text objects can
also used for defining initialized string arrays in
a similar way as variable arrays.
- Special
characters
within a string must be preceded by a '\': \n -
Line feed; \\ - Backslash; \" -
Quotation
mark.
-
Strings are similar to character sequences (char* or char[])
in C / C++, but have the advantage to be easier to handle for beginners because
their length is automatically adapted.
-
Character contents in C-Script can have a maximum length of 10000 characters;
there is no limit in lite-C.
-
The string length can't be changed in C-Script, but can be changed in lite-C
with str_cpy or str_cat.
-
Characters typed in the script - as in myfunction("Test!"); -
are a char array and not a STRING. This does normally not matter because
most engine functions accept char* as well as STRING* arguments,
but it does matter in special cases, like overloaded functions in lite-C
that depend on the types of the arguments.
Example:
STRING* playername = "Player1";
STRING* welcome = "Welcome to the new game!\n\nEnjoy!";
STRING* name = "#n";
Defines
a string pointer initialized to n
spaces. Use this for defining long empty strings.
Example:
STRING* sElements = "#100";
STRING name;
Defines an empty, variable length string (C-Script only - in lite-C, STRING*
name; would just define an uninitialized string pointer). The length of
this string can be changed by str_cpy or
str_cat instructions.
Example:
STRING sEmpty; // C-Script only: declare an empty, unlimited string