Sometimes a script needs user input - either to make choices or to trigger actions. Omniscope offers two particularly useful commands for this purpose.
The MENU command present the user with a menu, and records the user's response in the parameter list. The script can then examine PARAMS and take appropriate action.
The MENU syntax is MENU parameter "description" parameter "description" . . .
There may be any number of lines in the menu. For whichever line is chosen, the corresponding parameter is added to the parameter list. If no parameter is desired, use a single letter for the parameter.
: Set battery bank size
MENU LARGEBANK "Large Battery Bank" SMALLBANK "Small Battery Bank" X "Do Not Change Battery Size"
IF [PARAMS == LARGEBANK] {SEND 1FFC4 01 FF FF FF 00 04 FF FF}
IF [PARAMS == SMALLBANK] {SEND 1FFC4 01 FF FF FF 00 02 FF FF}
It is often smart to put a CLEARPARAMS command before the MENU command, especially if the script includes any loops.
The BUTTON command adds a line to the Monitor window which the user can click to trigger an action. It provides an easy way to create a "simulated control panel". The syntax is BUTTON "title" {command}
]
:A simple genset control panel
MONITOR GENSTATUS 1FFDC [B1] "Genset Status"
BUTTON "Start Generator" {SEND 1FFDA 01 FF FF FF FF FF FF FF}
BUTTON "Stop Generator" {SEND 1FFDA 00 FF FF FF FF FF FF FF}
The buttons stay active even after the script is complete, as does the entire contents of the Monitor window. Any command, including GOTO, can be triggered by a BUTTON.