|Page 137 of 800||Search internet|
Consider the following lgs source text:
""P my page ""D 6 " ++ " ""B "abc" ++ "def"
The body above contains two strings 'abc' and 'def' glued together by a ++ operator. In general, in a body, strings can occur anywhere an expression can occur.
One way of writing strings is to enclose a number of characters in double quotes as above. However, one may also start strings by a ""- escape sequence and may end them by a "". escape sequence. As an example, the following body is exactly like the one above:
""B ""-abc"". ++ ""-def"
Note that a string which starts with a ""- escape sequence does not need to end with a "". escape sequence. One can mix start end end marks arbitrarily.
The ""- escape sequence is ignored if it occurs inside a string. Hence, one can be sure to be inside a string after a ""- escape sequence regardless of whether one was inside or outside a string before the escape sequence.
The "". escape sequence denotes the empty string if it occurs outside a string. Hence, one can be sure to be outside a string after a "". escape sequence regardless of whether one was inside or outside a string before the escape sequence.
A lone double quote just toggles between being inside and outside a string. A missing or extra double quote somewhere in an lgs source text can cause errors which can be hard to locate. In a long text it may be beneficial to use ""- or "". escape sequences every now an then as it may make missing or extra double quotes easier to locate.
The empty string is special in that one cannot just enclose the empty string in quotes. That is so because if one encloses the empty string in quotes then that results in two quotes in a row which lgc(1) interprets as the beginning of an escape sequence. Thus, to include an empty string in an lgs source, use the "". escape sequence.
|Page 137 of 800||Search logiweb.eu|