ANSI ESC Sequences

ANSI ESC Sequences - also called ANSI commands - are useful for doing some display I/O control in REXX.

To use ANSI commands the OS/2 ANSI support must be active. To activate the ANSI support use the OS/2 command ANSI ON and to deactivate the ANSI support use the OS/2 command ANSI OFF. To get the current status of the ANSI support use the OS/2 command ANSI without a parameter. The default for the ANSI support is ON. (see Check if ANSI is active - 1 - or Check if ANSI is active - 2 - for REXX source to detect if ANSI support is active from within a REXX program)

Each ANSI command begins with the sequence ESC[. where ESC represents the ASCII code 1Bh (= 27 decimal). If there is more than one parameter for an ANSI command, use a semicolon (;) to separate the parameter.

To output ANSI commands you can use the functions LINEOUT and CHAROUT or the statement SAY. Example:

 
  say "1B"x || "[30;41m" || "This text is black on red"

  call lineOut , "1B"x || "[31;40m" || "This text is red on black"

  call charOut , "1B"x || "[0m" || "This text is in default color"

(see Using ANSI sequences for some sample code using ANSI sequences and RxLBox - menu routine in REXX is a menu program using only ANSI sequences to implement the navigation with cursor keys and function keys)

Note: To use the ANSI commands to set or get the cursor position you must use the function CHAROUT! (see SysCls for another minor restriction)