M Web Magazine 006 (March 5, 1998 - June 4, 1998)

MSM-Workstation Tutorial (part 3/5)

 

%%Macros

Something new in MSM Workstation is the use of macros. These are the commands one has to use to integrate with the GUI environment. The macros we have used in our program are:

%%DoWin(<what>) – Application: Add1 – Enter

This command (or the more generic %%Do) always have to be used so that control transfers from the Application (which is the first thing that is loaded) to the window in GUI programs. <what> would be the name of the window. For example, if you want one window to open another when a button is pressed, you would associate %%DoWin(<new_win>) to the event.

%%Cancel Window: Calc1 – CommonCode – Routine: QuitWin

Exits a window, destroying it. Pressing the close window button has the same effect of %%Cancel.

 

%%Get(<what>,<var>) – Window: Calc1 – CommonCode – Routine: UpdAns

Get the value of <what>, storing the result in <var>. <what> takes the form of object.property, eg Label3.ForeColor

 

%%SetVar(<l_var>) – Window: Calc1 – CommonCode – Routine: UpdAns and Routine: Init

With some objects, you can associate the value of the object to an M variable (a local variable - <l_var>). The macro %%SetVar will update the object variable based upon <l_var>.

 

%%GetChoice(<what>,<array>) – Window: Calc1 – CommonCode – Routine: ResetRdo

For those objects that are made up of lists (our radio button object has for elements: +, -. * and /), the %%GetChoice macro will retrieve into <array> the various choices of <what>.

%%GetChoice(op,oprarr)

will read the set up the array oprarr with the following entries:

oprarr(1)="+"
oprarr(2)="-"
oprarr(3)="*"
oprarr(4)="/"

 

%%ResetChoice(<what>,<array>) – Window: Calc1 – CommonCode – Routine: ResetRdo

This macro will remove any existing choices replacing it with what is defined in <array>. As with all %%*Choice macros, %%ResetChoice is aimed at those objects (<what>) that provide a choice from which users can choose.

 

%%SetSel(<what>,<array>) – Window: Calc1 – CommonCode – Routine: ResetRdo

Suppose you want to want to set the selected item of multi-choice objects? Fill <array> with those items to be selected and call the macro. In order to start the radio button with the + symbol selected we:

SET oprarr(1)="+"
%%SetSel(op,oprarr)

We will stop here with our program. Do appreciate that we have not covered all the different parameters that these macros can take. Check the help option if you want to find out more about them (until, that is, we re-examine them again in a future issue).

 

Midway

Those who are not new to M, have by now amassed a collection of M routines. Throwing all this hard work away is not something developers would look forward to. MSM Workstation comes complete with the traditional CHUI interface and using this product last time we developed two "traditional" M routines (INTRO001 & INTRO002). Today we will place a GUI menu system through which the routines we developed last time can be called.

The diagram above shows the components making up our module Menu. Besides the window ButtWin, we have also included the routines we developed last time. Observe the dimmed out buttons Drop and Add. These are used to respectively call in or removed already developed Objects, be they windows, routines, globals, etc (the drop down list at the very bottom of this box allow you to select the type of code you want to include).

The other thing about our application is what it will do when invoked (as was the case with the other applications we developed earlier). It will call the window ButtWin.

We won’t we going into too much detail with this application as most of the actions are similar to those we have discussed (besides, if you have MSM Workstation, you’ll find the source code of all the programs).

The diagram on the left opens up object Button1 which will be associated with the routine carrying the same name. When the button is clicked (action logic PUSH) we D ^INTRO001.

Do observe how very simple it is to create a menu system for your programs. It might be the first step in moving your systems to the Windows 95 platform. Also, using this method you can even turn them into stand-alone royalty free Executables. Simply set up the menu and the routines into an application and compile everything.

Continued...

E&OE

1