MSM-Workstation
Macros

Go back to the alphabetic list of macros
Go back to the first page of this tutorial

%%Do ( Name [ , Parameters [ , Settings ] ] )

Invoke a window or module, passing it parameters and settings.

Name A string literal (without quotes) representing the name of a window or module, or an at-sign followed by the name of a local variable (@name) where the value of that variable is expected to be equal to the name of a window or module at run-time.

Parameters Either an expression or a period, followed by the name of an (unsubscripted) array (similar to an array passed "by reference" to a subroutine or function). When the name of an array is specified, this array can contain both input and output variables stored in named subnodes. Within the called window the array is accessed using the macro %%IOVar. Any structure may be manipulated in this array.

Settings An expression or array containing properties and settings which will override property settings already in the window. Format alternatives are:

  1. Parent - If Settings is an expression not containing a "=", it indicates the name of the parent of the window
  2. Property list - Settings may specify multiple properties using the format: Property=Value|Property=Value|...
  3. Array - Settings may be a period, followed by the name of an (unsubscripted) array (similar to an array passed "by reference" to a subroutine or function). When this is the case, the parameter is assumed to be an array containing the specifications. The subscripts are names of properties, the values of the array elements are the corresponding property values.
    When this format is being used, properties of components can be defined as well as properties the window. If properties of components are to be specified, the value of the first subscript in the array must be the constant "C", the second subscript must be the name of the component, and the third subscript must be the name of the MWAPI attribute that corresponds to the property (reminder: names of properties look like "DefaultButton"; names of MWAPI attributes look like "DEFBUTTON"). Within the called window the array may be accessed using the macro %%Settings, although this is not normally necessary. When the parameter Settings corresponds to either of the first two formats, an array that corresponds to the third format will be constructed.

%%Do looks for a module named Name, and if one is not found it then looks for a window named Name. In this way a window may evolve into a module without the invocation of the window needing to change.

If a module is being done, the module program is called. If a window is being done, the window is loaded if necessary and made visible; focus is set to the starting control if any, and the compiled window program is called.

When a module is called using %%Do its Enter action logic is performed. Unless %%NotOK has been executed, when the Enter logic quits the Exit action logic is performed.

Examples

%%Do(@Name,,%%CurrWin)
Invoke a module. The name of the module to be invoked is the value of local variable Name.
In this case, the third parameter specifies that the current window is the parent of the invoked window.

S P("Pattern")="*.TXT"
%%Do(GetFile,.P)
I $D(P("File")) D ...
Create a parameter to be input into a window in array element P("Pattern") (presumably a pattern to be matched by candidate file names).
Call a window named "GetFile" (presumably to ask for the name of a file).
Do something if a value (presumably the name of a file) name was returned in array element P("File").

%%Do(Palette,.P,%%CurrWin)
Invoke a window called "Palette", send and return parameters in the array P().
In this case, the third parameter specifies that the current window is the parent of the invoked window.

See also

%%DoWin, %%OpenWin, %%Return and %%Cancel.