Tells the compiler to treat a backslash character inside a string (\) as an escape character.
'$CStrings [ Save | Restore ]
where: | means: |
Save | Saves the current $Cstrings setting. |
Restore | Restores a previously saved $CStrings setting. |
This treatment of a backslash in a string is based on the 'C' language.
Save and Restore operate as a stack and allow the user to change the setting for a range of the program without impacting the rest of the program.
The supported special characters are:
Backslash | \\ |
Backspace | \b |
Carriage Return | \r |
Double Quote | \" |
Formfeed | \f |
Horizontal Tab | \t |
Newline (Linefeed) | \n |
Null Character | \0 |
Single Quote | \' |
Vertical Tab | \v |
The instruction "Hello\r World" is the equivalent of "Hello" + Chr$(13)+"World".
In addition, any character can be represented as a 3-digit octal code or a 3-digit hexadecimal code:
Octal Code\ddd
Hexadecimal Code\xddd
For both hexadecimal and octal, fewer than 3 characters can be used to specify the code as long as the subsequent character is not a valid (hex or octal) character.
To tell the compiler to return to the default string processing mode, where the backslash character has no special meaning, use the '$NoCStrings Metacommand.
This example displays two lines, the first time using the C-language characters "\n" for a carriage return and line feed.
Sub main
'$CStrings
MsgBox "This is line 1\n This is line 2 (using C Strings)"
'$NoCStrings
MsgBox "This is line 1" _
+Chr$(13)+Chr$(10)+"This is line 2 (using Chr)"
End Sub
'$Include Metacommand [IBM CognosScript Extension]
$NoCStrings Metacommand [IBM CognosScript Language Extension]