CHARACTER MenuText*50, menus = "Replace; by your; own; menu; items; Help; items: Use MenuText or $$ in an if/then/elseif/else/endif construct; Good luck!;"
WINDOW(Ti="you name it", Menu=menus, SelTxt=MenuText, x=1, Win=w1)
only strings and arrays need to be declared in HicEst. All numeric scalars are 8-byte floating point, even obvious integers as w1 or $$ in this example
the CHARACTER line defines the variables MenuText as a string of length 50, and menus as a string with the length defined by the initialization argument
the WINDOW line opens a window with the handle w1, a title, and a menu.
The selected menu text is returned in MenuText.
With the Menu=menus option a "SUBROUTINE menus" is required to do the work when a menu item is selected. This is called a CALLback subroutine.
The x=1 option positions the window on the right border
. The item number selected is always in the global variable $$. In addition, when the menu window was created with the SelTxt option, the text string of the menu item is returned in the SelTxt argument
the WRITE line writes the values of $$ and MenuText the window with handle w1. The Name option prefixes the values with their symbolic names. ForeColor=$$ paints the output, ⇒ Colors
the IF line is a very short example of a conditional execution. Instead of the display of the WINDOW help dialog it is usually replaced by something like
IF($$ == 1) THEN
...
ELSEIF(MenuText == "Help") THEN
...
ELSEIF( KEY(SHift) * ($$ > 5) ) THEN
...
ELSE
...
ENDIF
the conditions are evaluated from top to bottom. Any kind of mixed logical expressions is allowed, e.g. the test whether the shift key is pressed AND the menu item nr is > 5. This can come handy while debugging your script.
the second END statement terminates the callback subroutine menus
After clicking a few menu items:
Surely, the WINDOW-menu or the WINDOW-Toolbar options are nice for well structured scripts. But if you are in a real hurry select File → New → button "Blank template, this window". This will open a minimalistic script
END
Here you are free to do the wildest things in the twinkling of an eye. But just remember this is bad style and it is not recommended. Unfortunately, most users seem do it anyhow, ourselves included
Make a few changes to the script to get the feeling:
close the window "you name it"
change the character string "menus". A ":" in a menu item will generate a