Hex Codes in Character Literals
Documentation | Blog | Demos | Support
Hex Codes in Character Literals
5 out of 5 stars
1 rating
5 Stars | 100% | |
4 Stars | 0% | |
3 Stars | 0% | |
2 Stars | 0% | |
1 Stars | 0% |
If you need a place a character not normally available from the keyboard into a character literal, use the backslash to create the hex code for that character as shown in the following example:
‘This string has an ASCII escape generated by hex 1B (1B)’
The two characters immediately following a quoted backslash are treated as hex code provided they are either digits from 0 to 9 or letters from A (a) to F (f).
Any character string containing a hex code must be enclosed in quotation marks.
Note: The escape function of the backslash inside quoted character strings can be switched off with a SET ESCAPECHAR command.
Example
Character literals that include hex codes can be useful for sending control codes to printers and terminals. For example, if the ASCII codes SI (hex 0F) and DC2 (hex 12) are used, respectively, to select and cancel condensed printing on your particular printer, use the following sequence of statements to print a report in the condensed mode:
set output printer % switch serial output to printer
output ‘F’; % switch condensed print on
…. commands to generate report ….
output ’12’ % switch condensed print off
set output terminal % switch output back to terminal
5 out of 5 stars
1 rating
5 Stars | 100% | |
4 Stars | 0% | |
3 Stars | 0% | |
2 Stars | 0% | |
1 Stars | 0% |