![]() ![]() ![]() ![]() | Table Of Contents | Index |
The OnKey statements control what is actually executed. OnKey statements also allow you to execute hidden commands when you do not want them to appear on the menu screen. One trick we use is to have an OnKey statement define a key that runs MarxEdit on each users personal menu file. We don't show this key on the menu to keep others from poking around in the file. For additional security a password can also be set up on this key.
Normally you enter a line of text as if you were creating a BAT file to run your application. Like batch files, if one of your commands is a batch file, all the statements after it will not execute. To prevent this you can use the CALL command to call a batch file in DOS 3.3 or later, or COMMAND /C in DOS 3.1 and 3.2.
Normally, text displayed under an OnKey statement is the same text as the batch file created by MarxMenu. There are some exceptions: If a line starts with a "|" (vertical bar), the line will be interpreted by MarxMenu instead of being written to a batch file. This allows commands such as "PASSWORD" to be used. String variables can be passed as part of a batch command if the name of the string variable starts with a "%" symbol.
The spaces preceding the commands under the OnKey statement are for clarity only. They are not necessary for MarxMenu to function properly.
Sometimes you need more control over what commands actually go into the batch file that MarxMenu executes. You might want to input test from the user or have the user make a choice from a list that will become part of the batch file that is executed. The BAT command is used to do this.
Let's say you want the user to enter the name of a directory to back up to a floppy. Here's how this might be done:
Example:Notice that the commands under the OnKey statement start with a vertical bar. This is because they are MarxMenu commands rather than batch file commands. Remember you are dealing with two languages here. MarxMenu understands MarxMenu commands and DOS understands batch commands. When you are under an OnKey statement all commands are written to a memory buffer which are written to a batch file when MarxMenu exits. DOS then runs this batch file. If you start a command with a vertical bar under an OnKey command then MarxMenu will see the command.
OnKey 'B' |DrawBox 15 10 55 3 |Write 'Enter Directory: ' |BackupDir = Readln |if (LastKey = Esc) or (not ExistDir(BackupDir)) | Return |endif |Bat 'XCOPY ' + BackupDir + ' A: /S' DIR A: PAUSE
The BAT command is a MarxMenu command that allows you to write lines to the batch file that is being created. It allows you more specific control of execution by allowing you to include MarxMenu variables in the DOS command.
![]() ![]() ![]() ![]() | Table Of Contents | Index |
|