Topic: APLX Help : Help on APL language : System Functions & Variables : ⎕CC Console Control
[ Previous | Next | Contents | Index | APL Home ]

www.microapl.co.uk

⎕CC Console Control


The monadic system function ⎕CC provides terminal-control facilities. With the exception of arbitrary output each ⎕CC operation is identified by a numeric code or code list which is included as the right argument to ⎕CC. The typical form of a ⎕CC expression is:

             RESULT←⎕CC OPERATION

where RESULT is the result of the operation and OPERATION is the appropriate code or code list. The numbers used as the right argument to ⎕CC must be integers (whole numbers). The ⎕CC operation specified is carried out, and in most cases an empty vector is returned as the result.

System Dependent

⎕CC is highly system dependent. On console-mode (dumb-terminal) implementations of APLX ⎕CC controls the user's terminal display. On windowing implementations (APLX for Windows and APLX for MacOS), it controls the Session window.

Single key input with ⎕CC

             RESULT←⎕CC ¯1

The code, ¯1, specifies that the next character entered on the keyboard is to be assigned to the named variable. No input translation takes place.

If the next key hit after the above statement has been executed is 'Z', then RESULT will contain 'Z'.

Arbitrary output with ⎕CC

             RESULT←⎕CC TEXT

The characters in the right argument are output to the screen without output translation. RESULT is an empty vector with display potential off.

Cursor addressing with ⎕CC

             RESULT←⎕CC 0 R C

You can move the cursor to a particular line and character position, by using the code 0, followed by the numbers of the row and column you require. Rows and columns start at 0. Invalid cursor positions are ignored.

The result of ⎕CC is an empty vector with display potential off.

             [3]  ⎕CC 0 10 20 ⋄ 'HELLO'

The cursor moves to row 10 column 20 and the text string 'HELLO' is printed.

Basic screen control with ⎕CC

Each of the following operations can be invoked by a statement of the form:

             RESULT←⎕CC code(s)

The required operation is carried out. The result returned by the operation is in most cases an empty vector with display potential off. (An exception is ⎕CC 20 which returns a numeric vector consisting of three elements.) Multiple codes can be output at one time (up to a maximum of 50), but all must be integers.

             RESULT←⎕CC 20

Returns a three element vector which contains the row and column where the cursor is positioned and the screen width.

The complete list of ⎕CC codes is as follows. Codes marked with an asterisk * are NOT implemented on the Windows, MOTIF or MacOS systems.

┌────────────────────────────────────────────────────────────────────────────────┐
│                        Operations Performed by ⎕CC                             │
├──────────────────────────────────────────┬─────────────────────────────────────┤
│ Code Operation                           │ Code   Operation                    │
├──────────────────────────────────────────┼─────────────────────────────────────┤
│ 1    Clear Screen                        │   19   Insert Character             │
│ 2    Home cursor                         │   20   Read Curs. Pos, Screen Width │
│ 3    Cursor to beginning of line         │   21   Insert Mode On               │
│ 4    Move Cursor Up One Line             │   22   Insert Mode Off              │
│ 5    Move Cursor Down One Line           │   23 * Half Intensity On            │
│ 6    Move Cursor Left One Position       │   24 * Half Intensity Off           │
│ 7    Move Cursor Right One Position      │   29 * Underlined characters On     │
│ 8    APL character set                   │   30 * Underlined Characters Off    │
│ 9    ASCII character set                 │   31 * Reverse Screen Video         │
│ 10   Erase from Cursor to End of Line    │   32 * Normal Screen Video          │
│ 11   Erase from Cursor to End of Screen  │   33 * Select 80  Columns           │
│ 12 * Protect Characters On               │   34 * Select 132 Columns           │
│ 13 * Protect Characters Off              │   35   Bell (Audible Alarm)         │
│ 14 * Protection On                       │   36   Bold Text On                 │
│ 15 * Protection Off                      │   37   Bold Text Off                │
│ 16   Delete Line                         │   38   Italic Text On               │
│ 17   Insert Line                         │   39   Italic Text Off              │
│ 18   Delete Character                    │                                     │
└──────────────────────────────────────────┴─────────────────────────────────────┘

On implementations which support color display, the following codes are also implemented:

 
┌──────────────────────────────────────────┐
│ 101   Black text                         │
│ 102   White text                         │
│ 103   Red text                           │
│ 104   Green text                         │
│ 105   Blue text                          │
│ 106   Cyan text                          │
│ 107   Magenta text                       │
│ 108   Yellow text                        │
└──────────────────────────────────────────┴

Other code numbers are reserved.

The operations which ⎕CC can perform depend on the capabilities of the terminal and/or system, but the following operations are almost always available:

             1 2 3 4 5 6 7 10 11 20
             ∇ TEST
       [1]  ⍝ EXAMPLE OF ⎕CC USAGE
       [2]  ⎕CC 1 2 ⍝          CLEAR SCREEN AND HOME TO SET ⎕CC (IF NEEDED)
       [3]  ⎕CC 0 10 10
       [4]  POSITION ←⎕CC 20
       [5]  ⎕CC 29 ⍝           UNDERLINE ON
       [6]  'I AM AT POSITION ',POSITION
       [7]  ⎕CC 30   ⍝         UNDERLINE OFF
       [8]  ∇

Topic: APLX Help : Help on APL language : System Functions & Variables : ⎕CC Console Control
[ Previous | Next | Contents | Index | APL Home ]