Directives
DEFCTL Define/Redefine CTL Values
   
Formats 1. Define/Delete CTL Values: DEFCTL [WINDOW] eom$={ctl_val | *}
 
2. Redefine CTL Values: DEFCTL [WINDOW | WINDOW+] ctl_val={alternate | *}
 
Where:
    * Asterisk deletes previously defined CTL value (e.g., DEFCTL eom$=* ). alternate
CTL variable's value. Numeric expression, integer.
   
  eom$ EOM (End-of-Message) character sequence. Generally provided as a Hex string expression (e.g., $0D$ for the Enter key).
  WINDOW[+] Optional keyword indicating,
    WINDOW: The setting is for the current window only.
WINDOW+: The setting is for the current window but also cascades to apply to lower level windows.
   
Description Use the DEFCTL directive to define additional CTL values; however, the replacement only occurs if the original CTL code is rejected. Use the DEFCTL WINDOW format to maintain the definition for the current window only. If WINDOW+ is used, the definition will cascade to lower level windows.
   
Format 1 Define/Delete CTL Values

DEFCTL [WINDOW] eom$={ctl-val | *}

Use DEFCTL to define an additional CTL value to be returned for a given EOM (End-of-Message) value or to delete one. The EOM string is the sequence of characters received from the terminal to end the current input. The first character of the string must be a non-printable character between $00$ and $1F$, or $7F$; e.g.,

0010 DEFCTL $09$=6 ! Set TAB key to return CTL=6
0020 DEFCTL $1B38$=7 ! Set HOME <esc>H to CTL=7
0030 DEFCTL $09$=* ! Delete control value setting defined @line 0010

The normal setting for the TAB key is to return CTL = -1015.

0010 DEFCTL $09$ = -1015

Positive CTL values will be returned to the program. Negative CTL values have special significance to ProvideX. (Refer to the list of Negative CTL Definitions, at the end of this document and see Function & Control Keys in the ProvideX User's Guide.) See also, the CTL System Variable, and the EOM System Variable.

   
Format 2 Redefine CTL Value

DEFCTL [WINDOW | WINDOW+] invalid_ctl= {alternate | *}

Use this format of the DEFCTL directive to define alternate CTL values to be applied whenever the specified CTL value is received and it would normally be rejected (e.g. A Page UP during a simple INPUT dircetive or Backspace when at the start of input).

For example, if you wanted to map the UP-ARROW (CTL=-1011) to return a CTL=3 whenever it was pressed and there was no valid location in the input to go to:

0020 DEFCTL -1011=3 ! Return CTL 3 on up arrow

Refer to the CTL( ) Function, and the CTL System Variable, for more information.

   
Creating a Hot Key ProvideX allows you to create a hot key that will CALL a program if it is pressed while the system is awaiting input.

To create such a hot key, define the control sequence that is generated by the key as a negative CTL value in the range -10 through -999. Then create and save your hot key program using the naming convention $CTL-num where num is the CTL value. Remember in your hot key program not to disturb the environment (i.e., do not close any files that are already open, but close any files you open in this program and remove any windows you create).

For example, the keystroke Ctrl -A returns $01$, which is defined in MY_START_UP program as a hot key:

1000 DEFCTL $01$=-500

ProvideX will call $CTL-500 whenever anyone hits the hot key Ctrl -A throughout the current session.

   
During Conversions When you convert BBx-style programs to ProvideX, it is sometimes necessary to have function and edit keys return single-character values. To do this, set both the
'EL' and 'FL' mnemonics and then use DEFCTL to redefine the mapped values and allow standard ProvideX functions to continue to operate. See also, 'EL' Mnemonic, and the 'FL' Mnemonic.
   
Example The following example redefines function keys F5 through F8 to return a single hex character ($F5$ through $F8$ respectively). It also maps some of the input edit keys to single character codes.
 
0010 DEFCTL $000074$=5 ! Reset F5 TO CTL=5
0100 ! ^ 100 - Map F5-F8 to return $F5$ through $F8$
0110 PRINT 'FL',"2"+CHR(4)+CHR(1)+$F5$, ! F5 = $F5$
 
0120 PRINT 'FL',"2"+CHR(5)+CHR(1)+$F6$, ! F6 = $F6$
0130 PRINT 'FL',"2"+CHR(6)+CHR(1)+$F7$, ! F7 = $F7$
0140 PRINT 'FL',"2"+CHR(7)+CHR(1)+$F8$, ! F8 = $F8$
0150 DEFCTL $F5$=5
0160 DEFCTL $F6$=6
0170 DEFCTL $F7$=7
0180 DEFCTL $F8$=8
0200 ! ^ 100 - Change Edit keys to single character
0210 PRINT 'EL',"2"+CHR(4)+CHR(1)+$01$, ! Home = $01$
0220 PRINT 'EL',"2"+CHR(5)+CHR(1)+$1A$, ! End = $1A$
0230 PRINT 'EL',"2"+CHR(6)+CHR(1)+$15$, ! PGUP = $15$
0240 PRINT 'EL',"2"+CHR(7)+CHR(1)+$06$, ! PGDN = $06$
0250 PRINT 'EL',"2"+CHR(8)+CHR(1)+$14$, ! Insert = $14$
0260 PRINT 'EL',"2"+CHR(9)+CHR(1)+$18$, ! Delete = $18$
0270 DEFCTL $01$=-1010 ! Home
0280 DEFCTL $1A$=-1018 ! End
0290 DEFCTL $15$=-1014 ! PGUP
0300 DEFCTL $06$=-1013 ! PGDN
0310 DEFCTL $14$=-1009 ! Insert
0320 DEFCTL $18$=-1007 ! Delete