Terminal Examples

This section contains examples of GT.M terminal handling.

Example:

    USE $PIECE:(ctrap=$c(3):exception="zg "_$zl_":C^MENU")
    

This example USEs the principal device, and sets up an EXCEPTION handler. If the device is a terminal, the USE also sets up a trap for <CTRL-C>. When an EXCEPTION occurs, it transfers control to label C in the routine ^MENU at the process stack level where the EXCEPTION was established.

Example:

    USE $PIECE:(X=0:Y=0:CLEARSCREEN)
    

This example positions the cursor to the upper left-hand corner and clears the entire screen.

Example:

    USE $PIECE:(NOECHO:WIDTH=132:WRAP)
    

This example disables ECHOing, enables automatic WRAPping, and sets the line width to 132 characters.

Example:

    USE $PIECE:NOCENABLE
    

This example disables <CTRL-C>.

Example:

    USE $PIECE:(PASTHRU:ESCAPE) R *X U $P:(NOPASTHRU)
    WRITE !,X,?5 I $L($ZB) W $A($ZB) F i=2:1:$L($ZB) W ",",$A
    ($ZB,i)
    

This USEs the principal device and, if it is a terminal, turns on PASTHRU and ESCAPE sequence processing. The READ *X places an ASCII code in X corresponding to the character read. The second USE turns off PASTHRU. The second line displays the resulting value for X and the ASCII codes in $ZB. $ZB holds the terminator, if any. This routine examines the input from all keys and key combinations on the keyboard except <CTRL-Q> and <CTRL-S>.