Creating the menus is often more difficult for the aspiring DCAL programmer than the actual macro itself. Take a look in the manual at the following functions:
Lblsinit - clears the labels (menu keys)
Lblset - put some text on a menu key
Lblsett - put some text on a toggle menu key (can be on or off)
Lblson - turns on the menu keys that you have set up
Lblmsg - associate a text message with a menu key
Wrterr - write some text to the error line
Wrtmsg - write some text to the message line
Wrtlvl - write some text to the 'level' line (the current menu display)
Those are the basic functions for creating a menu system. You will probably use most of these in any macro you write. The basic format for a menu is:
Clear the menu keys (lblsinit)
Set the labels and messages for your menu keys (lblset, Lblsett, lblmsg)
Tell the user what to do. i.e. select a point, enter a number(wrtmsg)
Wait for input (getchar, getpoint, etc)
optionally, you would provide some display of current settings (wrterr)
These 4 items are generally put into a loop (see REPEAT in the manual) that simply repeats over and over until the user does something. Once the user does something it is up to you to react accordingly.
Here is a quick example:
done : boolean;
key : integer;
done := false;
lblmsg(1, 'Do Nothing');
wrtmsg('Select a function:');
if key = S0 then
done := true;
All this example does is create a simple menu. The macro exits when the user selects S0 Exit. The use of the repeat loop and the DONE variable is fairly typical. The loop will simply repeat until DONE evaluates to true. Notice we set it to false before entering the loop. See that once the user presses S0 that done is finally set to true and the macro is allowed to end.
Consider this example as a basis for any macro. The example will compile and run just fine. Notice that the menu routine is isolated into its own procedure. When the macro is run DataCAD looks for the first BEGIN keyword that is not in a procedure or function. Toward the end of our example we simply call the MAIN procedure. You could call any procedure/function here or call several routines in sequence. This is a good macro template. Use it as a started for basic macros.
That should give you an idea how to create a basic menu system. Look at the sample macros for more in depth examples.
It is important to also talk about style. Stick with the way DataCAD works. Too often we see macros that are confusing simply because the programmer tries to change the way the menus and DataCAD work. You should not do this because you will confuse the user. Try to use buttons as buttons. Avoid the tendency to use a button as a label. The user will always try to click this label and question why nothing happens. Try to not cram all your menu keys onto one screen. If your menu looks cluttered consider breaking it into a menu-submenu hierarchy. Remember that users expect to have S0 (and thus right click) be EXIT. Take a look at DataCAD itself and some of the popular macros. Study how the menus are structured. Try to copy these examples.