TCL Macros

TCL macros allow users to perform simple batch tasks formed by combining TCL commands.

Types of Macro

Four types of macro are available: N (now) and M (modify) types, S-type sentences and TCL menus.

N- and M-types

These allow the execution of a sequence of TCL commands. M-type differs from N-type in that each command is presented to the user for editing before execution.

Refer to Command Definition Items for the format of an N- or M-type macro.

Notes

  • M-type macros use a reduced set of Editor commands. Press RETURN when prompted to execute the current command.
  • When run, parameters and TCL options supplied on the command line are applied to the first command in the macro in addition to any specified in the macro.
Examples:
    Banner
001 N
002 COMMENT (-1)(x7)(Logged on at: )+
003 TIME
004 COMMENT (port usr A/c of )+
005 WHO
006 COMMENT (Printer )+
007 SP-ASSIGN ?

The above clears the screen, sounds the bell and then displays (for example):

Logged on at: 08:27:24  24 Jun 2008  Tuesday
port usr A/c of 1 dm adt
Printer
Line#  Status   Copies  Form#  Device
    1    p           1      0

S-type Sentences

These are similar to N-type macros, but provide additional capabilities. In their simplest form, they are identical to N-type macros, but in addition they support the use of secondary commands (for example, SELECT followed by a command to process the selected items). Various item formats are supported, for compatibility with other MultiValue systems.

Refer to Command Definition Items for the format of an S-type sentence.

Note

When run, parameters and TCL options supplied on the command line are applied to the first command in the macro in addition to any specified in the macro.

TCL Menus

This type of macro presents a list of options to the user and then runs the TCL command associated with the selected option.

Refer to Command Definition Items for the format of a TCL menu.

Using a Menu

When the user runs a TCL menu, the screen is cleared and the menu items are displayed in columns across the screen, with the number columns determined by the screen width and the length of the longest item text. Each menu item is given a number.

Note

The layout of the menu on the screen is different to that on some other MultiValue systems.

The user is then prompted:

"Enter menu selection (append '?' for Info), TCL command, or <CR> to exit:"

Note

If there are more items than can be displayed on the screen, the prompt is:

Enter menu selection (append '?' for Info), TCL command, or <CR> for more.

The user can then enter the following:

Example:
    MENU1
001 ME This is an immediate comment!
002 This is the MENU title
003 Time nowvmtime?vmTIME
004 Database space usagevmSpace leftvmPOVF
005 List Menusvmdisplay list of MD menusvmSSELECT MD WITH A1 = "ME]"vmLIST MD
006 Whovmlist uservmWHO

When run, this TCL menu displays the following:

 This is the MENU1 title
1) Time now               2) Database space usage   3) List Menus
4) Who
Enter menu selection (append '?' for Info), TCL command, or <CR> to exit:

If the user enters 1  at the prompt, the time is displayed; for example:

15:26:15  30 Jul 2008
Hit any key to return to the Menu.

When the user presses a key, the menu is redisplayed.

Creating Macros

Macros are items in the MD of an account. You can create them with any of the Reality editors, or by using the .C TCL Stacker command to save commands from the stack as an S-type sentence. If a different type of macro is required, you must use one of the editors to modify the saved item.

Macro Commands

You can include the following special commands in your macros:

DISPLAY command This displays a message to the user. The message can include literal text, the output of one or more TCL commands and various control sequences. An option allows the user to specify which MultiValue video codes are used (to simplify migration).

This command can also be used in Procs.

PROMPT command
This displays a message to the user in the same way as the DISPLAY statement, but it then waits for the user to enter C  (continue) or Q  (quit). If Q  is entered, none of the subsequent commands are executed.

COMMENT command
This provides similar functionality to the DISPLAY statement, but uses a different syntax.

REM command This allows remarks to be inserted into macros. All text which follows, up to the end of the line, is ignored.

Executing Macros

You can run a macro of any type from the TCL command line. In addition, you can load an S-type macro onto the TCL stack using the .X TCL Stacker command and execute the commands it contains from there. This is intended primarily for executing macros that were saved from the stack; any secondary input will be ignored.