This type can contan text. ie. a word, a sentence, or a book. Note
that this is not simply the letters A to Z, special characters,
null characters, newlines can all be stored in a string. Any 8-bit
character in fact. Strings are a basic
type in LPC, as opposed to C where strings are represented by an
array of char. This means that you cannot set individual characters
in a string with the index operator for instance. In fact, there are
no functions that alters strings destructively. Also, all strings
are 'shared', that means that if the same string is used in several
places, only one will be stored in memory.
When writing a string in a program, you enclose it in doublequotes.
To write special characters you need to use one of the following
syntaxes:
- \n
- newline
- \r
- carriage return
- \t
- tab
- \b
- backspace
- \"
- "
- \\
- \
A list of operators that applies to strings follow:
In this list a and b is used to represent a string expression:
- a + b
- summation ( "a"+"b" returns "ab")
- a - b
- subtraction ( same as replace(a,b,"") )
- a / b
- division ( same thing as explode(a,b) )
- ! a
- boolean not, returns 0
The following operators compare two string alphabetically:
- a == b
- return 1 if a is equal to b, 0 otherwise
- a != b
- return 0 if a is equal to b, 1 otherwise
- a < b
- returns 1 if a is lesser than b, 0 otherwise
- a <= b
- returns 1 if a is lesser or equal to b, 0 otherwise
- a > b
- returns 1 if a is greater than b, 0 otherwise
- a >= b
- returns 1 if a is greater or equal to b, 0 otherwise