WIL menus are defined in a menu file, which is simply a standard ASCII text file (the kind created by Notepad). Each menu file consists of one or more lines of menu statements. Each line is terminated with a carriage return / line feed (CRLF) combination, and can be up to 2048 characters long. Generally, these files have an extension of .MNW. See your product documentation for the name of the default menu file that it uses. Every menu file contains one or more menu items. When activated they appear as drop-down menus. They may also contain top-level menu names which show up in a main menu bar (refer to your product documentation for more information). Each menu item consists of a title which identifies the item, followed by one or more lines of menu code which the WIL Interpreter will execute when you choose the item. Essentially, your menu file is an outline of menu options, formatted with specific spacing, and containing snippets of code. There are two main parts of a menu file:
Menus can be up to four levels deep. Levels are determined by the position of the first letter in the menu title. The top level menu starts at Column 1, the second starts in Column 2, and so on. The WIL code must begin at Column 5 or greater. Same level menu items must be separated by WIL code or a submenu. In the example below, Option #1 and Option #2 are separated by the WIL code which is to be executed. &Top Menu (Lvl 1) Option 1 (Lvl 2) Submenu of Option 1 (Lvl 3) Submenu of Submenu of Option 1 (Lvl 4) WIL code
Option 2 (Lvl 2) Submenu of Option 2 (Lvl 3) WIL code
This script creates the following menu in the Windows Explorer.
Your application probably included a pre-defined sample menu. Refer to it for a practical example of correct menu structure. Here is another example of an extremely simple menu file: &Games &Solitaire Run("C:\Program Files\Microsoft Games\Solitaire\Solitaire.exe", "")
The first line, &Games, begins in column 1, and therefore defines a top-level menu item. Depending on the product you are using, it may either appear on a menu bar or it may appear on the first-level drop-down menu. The ampersand (&) is optional; it defines an Alt-key combination for the entry (Alt-G in this example). It will appear in the menu as Games. The second line, &Solitaire, begins in column 2, and defines the title for an individual menu item. Again, the ampersand (&) is optional. It defines an Alt-key combination of Alt-S. This item will appear in the menu as Solitaire. The third line, Run("C:\Program Files\Microsoft Games\Solitaire\Solitaire.exe", ""), is the actual code which will be executed when this menu item is selected. Like all menu code, it must be indented at least four spaces (i.e., it must begin in column 5 or higher). This third line is really the entire WIL program; the two lines above it are simply titles which define the position of the program (i.e., the menu item) in the overall menu structure. Here's a slightly expanded version of the program: &Games &Solitaire Display(1, "Game Time","About to play Solitaire") Run("C:\Program Files\Microsoft Games\Solitaire\Solitaire.exe", "")
Here, we've simply added a line of code, changing this into a two-line program. Notice that each additional line of code is still indented the same four spaces. Now, let's look at a menu file which contains two menu items: &Games &Solitaire Run("C:\Program Files\Microsoft Games\Solitaire\Solitaire.exe", "") &Minesweeper Run("winmine.exe", "")
We've added a new menu item, Minesweeper, which begins in column 2 (like Solitaire) and will appear under the top-level menu item Games. To add a new top-level menu item, just create a new entry beginning in column 1: &Games &Solitaire Run("C:\Program Files\Microsoft Games\Solitaire\Solitaire.exe", "") &Minesweeper Run("winmine.exe","") &Applications &Notepad Run("notepad.exe","")
Now there are two top-level menu titles, Games and Applications, each of which contains two individual items (the blank line between Games and Applications is not necessary, but is there just for readability). In supported applications such as FileMenu, a comment can be displayed on the status bar in the Windows Explorer. This works only for top level menu items. The comment must be on the same line as the top level item. For example, the menu item below is a main menu for running Games. "Killers of Time" is the comment that appears in the status bar. &Games ;Killers of Time &Solitaire Run("C:\Program Files\Microsoft Games\Solitaire\Solitaire.exe", "")
In addition to top-level menus, you can optionally define up to 3 additional levels of submenus. The titles for the first-level, second-level and third-level submenus must begin in columns 2,3 and 4, respectively, and the individual menu items they contain must be indented one additional column. For example: &Applications &Editors &Notepad Run("notepad.exe","") &Studio Run("WinBatchstudio.exe","")
In the above example, Editors is a submenu (beginning in column 2), which contains two menu items (beginning in column 3). Studio also begins in column 2, but since it does not have any submenus defined below it, it is a bottom-level (i.e., individual) menu item. Here's an even more complex example: &Applications &Editors &Notepad Run("notepad.exe","") &Studio Run("WinBatchstudio.exe","") |&Spreadsheets &Windows-based &Excel Run("excel.exe","") _&DOS-based &Quattro Run("q.exe","")
We've added an additional level of submenus under Spreadsheets, so that the bottom-level menu items (Excel and Quattro) now begin in column 4. There are also two special symbols presented in this menu: the underscore (_), which causes a horizontal separator line to be drawn above the associated menu title, and the vertical bar (|), which causes the associated menu title to appear in a new column. Note: The vertical bar (|) will only work on top level ( Column 1 ) menu when used in context menus. Some applications allow you to place an individual (bottom-level) menu item in column 1: &Notepad Run("notepad.exe","")
in which case it will appear on the top-level menu, but will be executed immediately upon being selected (i.e., there will be no drop-down menu).
|
§ Step by step guide to learning WIL
|