Character (Obsolete Command)
Obsolete
This command is replaced by the Character function.
Purpose
To convert an integer between 0 and 255 to its equivalent ASCII character, and place the character in a variable.
Syntax
character
ascii_num
to
ascii_char
What It Does
The character command converts a number (ascii_num) to the single ASCII character (ascii_char) represented by the number in the ASCII character table. This is often useful for special device controls such as ringing the bell or setting a printer.
string bell 1
character 7 to bell
show bell
This declares a one-character string variable called bell, and moves the "beep" character (ASCII value 7) to bell. The show bell statement will cause the computer to beep anytime thereafter in the program.
Notes
-
The
charactercommand is useful for creating strings for printer and other device control, in cases where you can't conveniently create the strings from the keyboard. -
The
asciicommand does the reverse ofcharacter; it converts the first character of a source string to its ASCII value and places the result in a variable. -
Most printers and many other devices use the escape character (ASCII value 27) to begin a control sequence. The following example will set an Okidata 192 printer to its double-width printing mode, print one line, and then reset to normal mode:
string esc 1 direct_output "LST:" character 27 to esc write esc "W1" // Turn double width on writeln "LINE OF DOUBLE WIDTH PRINTING" write esc "W0" // Turn double width off -
ASCII values for the
charactercommand must be represented as decimal (not hexadecimal) numbers. -
ascii_numandascii_charmay be the same variable.