18.3.4 string
The string-type is a basic data type that indicates a variable-length character string.
The keyword string allows you to declare and initialize a string-type variable or constant. You can use this keyword only in the DEFINE section. When you specify two or more variables after this keyword, use a comma (,) to delimit them.
You can declare a constant by using the keyword const in combination with the keyword string. The values of the constants declared in the DEFINE section can only be referenced, and cannot be changed in the MAIN or ERROR section.
To specify a character-string constant, you have to enclose the character string with double quotation marks ("). If you want to use a double quotation mark (") in a character string, place a single quotation mark (') immediately before the double quotation mark.
- Organization of this subsection
(1) Format
DEFINE { [const] string variable_name1 [= "StringValue"] [, variable_name2 [= integer_constant2]] ; }
(2) Example of coding
DEFINE { string CaptionName="Setup"; // Valid string ErrorText; // Valid }
(3) Notes
-
The length of a string-type variable may be increased as a result of combination.
-
All variables that have not been assigned any value become empty. In the example shown in (2) above, ErrorText is empty.
-
You can write the value of a string-type variable over two or more lines by placing an underscore (_) at the end of the preceding lines. In the following example, the value of string-type variable ErrorText is Sample testing success.
Example:
DEFINE { string ErrorText = "Sample_ Testing_ success"; // string is written over multiple lines. }
-
The following characters are handled as special characters in a character string.
Character
Handled as:
\n
Line feed
\r
Return
\t
Tab character
'\
Backslash (\)
'"
Double quotation mark (")
''
Single quotation mark (')
In the following example, the character-string variable ErrorText is assigned "Sample Testing".
Example:
DEFINE { string ErrorText = "'"Sample Testing'""; // Sample Testing is enclosed in '"...'". }
In the following example, the character-string variable Path is assigned C:\Windows\system32.
Example:
DEFINE { string Path = "C:'\Windows'\system32"; // "C:\Windows\system32" is assigned to Path. }