Define string depending on getvar value
ArborX


Summary
The simple example below uses getvar to determine the current operating mode and, depending on what it is, defines string no.390 with a macro that could appropriately be assigned to the keystroke +.

The simple example below uses getvar to determine the current operating mode and, depending on what it is, defines string no.390 with a macro that could appropriately be assigned to the keystroke +.

  1
 "ts", "389" 2
 $getvar 01505 "Mode"<> 3
 $defstr 390,""<> 4
 $?=^Mode addstr 390,"tdpctrl\n" }end<> 5
 $^Mode- -<> 6
 $?=^Mode addstr 390,"tfbgc\n" }end<> 7
 $^Mode- -<> 8
 $?=^Mode addstr 390,"tic\n" }end<> 9
 $^Mode- -<> 10
 $?=^Mode addstr 390,"tgfcol\n" }end<> 11
 $:end<> 12
 $trun 390<> 13
4
String header. (In this illustration the script is shown as if it was set in an suser.3ad file).
6
Use getvar to obtain a numeric code, from 0..3, for the current operating mode.
8
Define an empty string no.390.
10
If the ^Mode variable has a value of 0, then assign macro to be accessed from Document Mode, and jump to the label on line 11.
12
Decrease the value of the ^Mode variable by 1. If getvar had returned a value of 1, the new value will be 0, allowing the next line to be run, and so on. Decreasing the value of a variable in this way is efficient and allows simpler tests than for a specific value.
11
The target label for lines 4, 6, 8 and 10.
12
Run the script that has just been define.

Document created on 2-Apr-2003 (revision 001)