Skip to content

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 character command 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 ascii command does the reverse of character; 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 character command must be represented as decimal (not hexadecimal) numbers.

  • ascii_num and ascii_char may be the same variable.