Download VNMR 6.1C User Programming

Transcript
Chapter 1. MAGICAL II Programming
Listing 3 shows what a typical menu looks like (this menu is somewhat simplified from the
actual system menu). In this menu, the first three lines is a comment with the name of the
menu. Like regular macros, comments are indicated by double quotation marks ("...").
Listing 3. Typical Menu
mlabel=' '
mstring=' '
mlabel[1]='Plot'
mstring[1]='pl'
mlabel[2]='Scale'
mstring[2]='pscale'
if (plotter='HP7550A')or(plotter='HP7570A')
or(plotter='HP7570A_C')or(plotter='HP7570A_D')
or(plotter='HP7475A') then
mlabel[3]='HP Params'
mstring[3]='hpa'
else
mlabel[3]=' 'mstring[3]=' '
endif
mlabel[4]='Params'
mstring[4]='ppa'
mlabel[5]='All Params'
mstring[5]='pap'
mlabel[6]='Peaks'
mstring[6]='ppf'
mlabel[7]='Page'
mstring[7]='page menu(`display_1D`)'
mlabel[8]='Return'
mstring[8]='menu(`display_1D`)'
In the first active line of the menu, mlabel and mstring are set to a null string. This
removes any trace of the previously active menu. After that, a series of assignments are
made for each of up to eight values of mlabel[i] and mstring[i].
The labels are just that, button labels, and hence can contain anything appropriate. The
strings, on the other hand, are themselves macros to be executed later, and hence they must
contain valid commands, parameters, macros, and other MAGICAL language statements.
In Listing 3, strings 1 through 6 contain a single command. If one of these buttons is
selected, the command is executed, and the same menu is reactivated. String 7, however,
issues a page command and then a second command that changes to the “display_1D”
menu. The assumption here is that several of the choices 1 through 6 may be made on a
single plot, but that once choice 7 is made, the user is finished with this menu and wants to
revert back to the “parent” menu.
Note the reverse quotation marks (`...`) in strings 7 and 8, which are converted to regular
quotation marks when the string is executed.
The sample menu in Listing 4 illustrates additional features of menus.
Notice the new features in this menu:
• The clear command appears near the start of the file. Executing clear(2) clears
the graphics window. Because this command is in the menu itself and not in any
particular string, it is executed each time the menu is activated.
• A number of comments are included in addition to the title—these are perfectly
permissible and are encouraged to make the statement action clearer.
56
VNMR 6.1C User Programming
01-999165-00 A0800