Menu configuration files
The menus used by the system are stored in text files which can be edited to change the wording, entry order, and submenu hierarchy. Each menu entry contains two parts: the external appearance, and an internal value returned to the program when it is selected. When the application receives the menu value it does not need to know how the command was spelled or what menu or submenu it came from. The set of commands that the system understands at any particular time is of course restricted; you cannot request "pipe routing" while you are doing annotations, for example.
To make the lists of available commands more manageable, related commands are grouped into submenus so you do not have to see all the commands for all the modules at the same time. In the menu files this hierarchy is indicated when the entry refers to another menu file. The name of the top of this hierarchy is fixed, however, since the program looks for that menu first when reading the menus. After loading the top menu it then loads any submenus referenced from it, and sub-submenus referenced from those, and so on. The references may not be circular, however—a menu cannot refer to itself either directly or indirectly through other menus.
The entries for menus are usually written on separate lines, but they also must be delimited by double semicolons. The first entry in a menu file is always the title record of the menu. The following attributes can be given to the menu using data fields in the title record:
Here is an example from the "document management" menu:
nco 1;;
str Generate Data for Isometric;val 15100;;
str Listings;sub lists.m;;
str Drawing menu;val 15300;;
str Help;val 15099;;
The first line only says that the items should be arranged into a single column. The numbers used in the "val" parts only have meaning to the program. The menu references "lists.m" which is shown next:
nco 1;;
str List Components;val 15201;;
str List Materials;val 15202;;
str List Materials of a Pipeline;val 15203;;
The following attributes are allowed on the first line:
Field name |
Description |
---|---|
nco |
The number of columns displayed. |
tit |
The title string for the menu. |
nam |
The name for the menu, as seen by the program. If not specified then the file name is used also as menu name. |
The rest of the records define the menu items for the menu. Attributes can be given to an item using the following data fields:
Field name |
Description |
---|---|
hdr |
Inactive, bolded heading text to display in the menu. Use this to create a non-clickable heading for a group of related menu items. |
ind |
The indentation of the menu item. Use this to indent the items under an inactive heading. |
str |
The text to display on the screen for this item. |
val |
The value of the item as an integer number or an ASCII character enclosed in single quotes: 'a'. |
icn |
The name of an icon file (search path mapped via the environment variable XBMLANGPATH). If present, then the icon will be displayed instead of the item string. Icons are found in the adjacent directory ../*icon*; the name depends on the windowing system you have. Environment variables can be used in icon names embedded in menu or panel definition files. Also it is possible to use full path names. |
sub |
The name of the submenu to be activated when the item gets selected. As a name or relative path name, the path is relative to the directory in which the menu lives. The sub name can also be an absolute path, a name starting with "/". |
dat |
A string that associates some application-specific data with the menu item. |
opt |
The menu selection is only posted if the argument file/directory of the "opt" tag exists. |
Any field value may refer to an environment variable. This is done in the standard way: $var_name. The environment variable is substituted with the value assigned to it. This is used to get menus in other standard directories.
Trailing white spaces matter in "val" fields, so for example val 'p'; is correct but val 'p' ; is not.
Executing CADMATIC scripts from menus
A menu item can be configured to execute a CADMATIC script when it gets selected. The script to be executed can be either in the project-specific script library or it can be in a separate script file.
Menu item value 1001 directs CADMATIC applications to execute a library script. The menu item's "dat" field should contain a call to the script using the following example syntax:
example_script(20, 2.45, "Hello world", ?).
The argument list must conform to the formal parameter list specified for the script. Numeric arguments are converted from integer to float if the formal parameter is explicitly typed as a float and vice versa. String type arguments must be enclosed between "" characters. A question mark directs the applications to prompt for the value of the respective parameter before the script is executed.
Menu item value 902 directs the application to execute a script in a script file that is either specified in the menu item or prompted from the user. If the menu item has no "dat" field then the user is requested to select the script file. In this case the name of the script to be executed is "main" and the user is prompted for values of parameters in case the script has declared them.
Otherwise the menu item's "dat" field contains the path name of the script file and a call is made to the script using the following syntax:
macro/goodies.mac goodie(3.141).
The specified script file can be either a compiled script file or a source script file. Also it can be specified via a full path name or a relative path name.
If the script file ends with the suffix .bs then it is assumed that the file is a loadable, compiled script file. Otherwise the given file is assumed to be a source script file. In this case the system first has to determine if the compiled file already exists and also is newer than the source file. Otherwise the source file has to be compiled. To do the compilation the applications runs the program DM_SC.
Compiled versions of script files are preserved for script files located either under project shared directory sde/src or under system directory %PMS_HOME%. Otherwise the compiled script file is thrown away after it has been loaded into memory (naturally only if it was compiled from a source file).
If the script file is specified via a relative path name (does not begin with a "/") then it is searched from two directories : proj/sde/src/xx and %PMS_HOME%/xx, in this order. In case a compiled script file is specified then directories proj/sde/host.bin/xx and %PMS_RUNDIR%/xx are searched. In the above xx denotes the CADMATIC product to which the application belongs.