Command Line Menus

Let’s consider the pros and cons of using command line menus rather than keyboard string menus in the above example. The main two shortcomings of keyboard string menus are that you have to be careful to disable them as soon as the program’s input context changes, and you can only perform actions that can otherwise be performed with the keyboard. This latter comment may not seem like much of a "shortcoming" until we consider the benefits of being able to add functionality to programs via menus without otherwise modifying the programs. The help menu item in the previous example is a good illustration of this; it adds a capability (viewing documentation in Acrobat) to your program that may not have been previously implemented via keyboard commands. Furthermore, it can be added to the menu once and left there to be used from any of the programs in your application.

The command line menu type overcomes both of the above shortcomings. First, the commands are executed independently of your program context and thus you don’t need to worry as much about changing the menu items as the program changes state. Second, you can execute any legal Windows command line, and thus you are not at all bound by the limitations of your application. For example, you can launch desktop utilities like the calculator (calc.exe), or entirely new applications, like a backup or email program. However, you might wonder what good this does when all you want to do (in the case of our simple accounting menu example) is select and run a program within A-Shell. It turns out you can use the command line approach for this case as well. The trick is to launch a new instance of A-Shell. Consider the following excerpt from our MDF, this time using the command line approach:

TOP,"&G/L",SUB

&G/L,"Account Maintenance", CMD,"$ASHELL –e run glamnt"

&G/L,"Period Maintenance",CMD,"$ASHELL –e run actmnt"

&G/L,"Transaction Entry", CMD,"$ASHELL –e run trxedt"

&G/L,"Financial Statements", CMD,"$ASHELL –e run finstm"

 

TOP,"&Utilities",SUB

&Utilities,"Calculator", CMD,"calc.exe $"

Here we used the special macro $ASHELL, which the MDF logic understands to mean launch another instance of A-Shell using the same A-Shell executable and MIAME.INI file as the current instance. The remainder of the command line simply runs the specified program, counting on the fact that the new instance of A-Shell will start out logged in to our current directory. If the programs were in another directory, we would either have to specify their location, or perhaps use a command file to first log us to the proper location and then run the program. The –e switch forces the instance to terminate when the specified program returns to the dot prompt.

The new instance of A-Shell will be on top of the original instance, which will be suspended until the new instance terminates. At that point, you’ll be right back where you started.

This approach has the potential advantage that it might be applicable anywhere in the application. For example, you might be in the A/P voucher entry program and want to look up an account in the G/L. Rather than exit the voucher program to switch to G/L, you might just select the G/L Account Maintenance option from the menu, launching a new instance for that program, then return to the original program when done.

There are, however, some shortcomings to this approach as well. First, it requires that your programs can be run from the dot prompt without first going through some security logic in the main menu. (Many applications load some kind of security or other context information into memory within the main menu, which is needed by other programs in the application. In such a case, the above plan would not work.) Another potential problem might be confusion on the part of the user over how to get back to where they were.

Note that you don’t have to suspend the original instance while the new instance is running. It might make more sense in this case to allow the user to operate as many independent sessions as they like, toggling between them at will. You can accomplish this by adding a " $" to the end of the command line string (e.g. "$ASHELL –e run actmnt $".) (We chose to do this with the calculator item so that we wouldn’t have to close the calculator after each use.)