![]() ![]() ![]() ![]() | Table Of Contents | Index |
Example:In the above example if 'W' is selected, MarxMenu will create a temporary batch file containing all the lines under the OnKey command. All the lines under an OnKey are written literally to the batch file with few exceptions. All leading and trailing blanks are stripped. String variables are evaluated and their value passed if the name of the string variable name starts with a '%'.
Onkey 'W' cd\wordstar ws cd\menu
If a line begins with a '|' (vertical bar), the line is interpreted rather than written to a batch file. If a '^Label' is used under an OnKey, a jump is made to the 'Label' and interpretation is resumed. This is commonly used to jump to a submenu.
Another way to include MarxMenu variables and have more control inside the batch file is to use Bat commands. Bat commands are MarxMenu commands that create lines in the batch file you are creating.
Any OnKey statement that causes a batch file to be written to will cause the menu to exit. MarxMenu normally will exit with ErrorLevel 0 unless an ExitCode is set.
The first blank line under an OnKey ends what is written to the batch file. One common mistake is that when MarxMenu commands are intermixed with batch file statements, all the MarxMenu commands are executed first. This is because the batch statements are written to a batch file and executed when MarxMenu exists.
Example:The above example won't work. Here's why. MarxMenu changes to the c:\wordstar directory. Then it stores WS in a batch file buffer. Then it changes to the c:\menu directory. Then MarxMenu writes the batch file and exits and you are in the wrong directory.
OnKey 'W' |ChDir('c:\wordstar') WS |ChDir('c:\menu')
Here is an example of using conditional statements under an OnKey command:
Example:In the above example MarxMenu tests to see if a color-compatible screen is available. If so it runs SMART out of the color directory. Otherwise it runs SMART out of the mono directory. Note that all commands that MarxMenu sees start with the vertical bar character.
OnKey 'S' |if DisplayType = 'HERCMONO' |ChDir('C:\MONSMART') SMART |else |ChDir('C:\COLSMART') SMART |endif
Sometimes you want to execute a command where the command is created by a complex set of rules. The BAT command is useful here.
Example:In this example the |Bat command allows more specific control over what is sent to the batch file for execution.
OnKey 'P' |Bat 'CAPTURE Q=' + Queue + ' C=1 NB NFF TI=5 Local=' + PrnPort
See Also: | MxCmd | Bat | UseArrows | OnScreenOnly |
---|
Category: | Conditional |
---|
![]() ![]() ![]() ![]() | Table Of Contents | Index |
|