Multi-Value Solutions - Aug '97

Nathan Rector

Natec Systems

Where would Macros be used? What can you do with macros? How do you create macros?

The macros that I am talking about are used to help execute groups of commands from TCL, not the keyboard macros that are commonly found the Windows or Mac environments.

Macros execute a group of TCL and Basic programs in order from top to bottom. They are helpful when you need to create reports, or need to execute a one time group of processes automatically.

Most of the new Multi-value operating systems have phantom ports. These ports are used to execute TCL verbs in the background without taking up a physical port. Since phantom ports process only one TCL command at a time before taking the next item in the queue, there is a high likelihood that groups of processes will not be executed together. This is where macros come into play.

This also goes for any group of TCL statements that a user doesn't wanted interrupted on a normal terminal.

Depending on what Multi-value operating system you are working with, there are as many as three ways to create macros. All of the Multi-value systems have PROC. Most of the newer systems have a function called Paragraphs and functions that are specifically called 'Macros'.

Paragraphs allow a user to create basic prompt/variable systems that can be fed into TCL verbs listed later in the macro.

'Macros' are just list of TCL statements. They execute the TCL statements and that is all.

In this article I'll talk about Paragraphs. Paragraphs are one step above the standard execute macro that just processes commands from top to bottom. With paragraphs you are able to ask for basic information and save that information into environmental labels.

These labels can then be included into an ACCESS statement to create more interactive macro.

The format of a paragraph is very simple. In attribute 1, place a 'PARAGRAPH' or in older version "PA" and "T". This tells the operating system that this is not just a data item. Anything after then 'PARAGRAPH' is executed as part of the paragraph.


002 * lists information in specified bid file

003 list <<c2>> (<<Press 'P' to print>>

There are a few additional commands that you can use to create the interaction of the paragraph. These commands allow you to do a lot of things that a simple program can do. For example, loops, stack data, conditional statements, and GOTO statements.


Comments allow the user to document what each command does or describe the whole paragraph. Commenting works the same as you would find in a BASIC program; anything after an asterisk (*) is the comment.


002 * this is an example of a comment. This information will not be

003 * displayed. Now processing the list statement

004 list md


It is possible to have the paragraph ask the user for information as it processes. To do this, place the question to be asked between double greater and lesser than signs.


002 * example of input

003 list <<Enter filename>>

This displays the following when the paragraph is run:


Enter filename>

There are more complex additions you can add to the input statement. One of these additions is the ability to read information from the TCL command line. By placing a 'C' and a number between double greater and less than signs the paragraph can read information on the command line. The number specifies the word at that position delimited by a space. For example, if you have a TCL statement of "listfile md" and place <<c2>> in place of the <<Enter filename>>, then the it processes the md file instead of asking for the file name.

The only problem with this is that if you don't specify the a file name after the 'listfile', then the paragraph has no file to process. If you want the paragraph to ask for the input if something is not specified at the command line, then use the 'i' indicator: <<i2,Enter Filename>> The 'i2' checks to see if there is something in the second position of the command line. If not, then it displays "Enter Filename".


002 * example of the 'i' indicator

003 list <<i2,Enter filename>>


Enter filename>

:listfile md

displays the md file.

The normal operation of the input command saves the information input in a "variable" with the name of what every prompt displayed was. If the same prompt display is used again in the paragraph, then it uses the information that was input the first time.


002 * more than one prompt

003 select <<Enter File>> with "" = "junk]"

004 list <<Enter File>>


Enter File>

This selects the item "junk' from the file enter and displays the same file input. If you want the prompt to be asked for each time, then use the 'a' indicator. This causes the prompt to always ask for information even if there is data present.


002 * prompt more than once

003 select <<Enter File>> with "" = "junk]"

004 list <<a,Enter File>>


Enter File>

Enter File>

There is one more indicator that is useful in paragraphs. This is the repeat indicator, or the 'r' indicator. The 'r' indicator causes the prompt to keep asking for input until a null value is input. It then strings these value together into a string separated by spaces.

There are a few more things that the input can do, but they are beyond the scope of this article.


Conditional statements are standard IF-THEN-GO statements. It supports the '>' or 'g' for greater than, '<' or 'l' for less than, '=' or 'e' for equals to, and '#' or 'n' for NOT equals to. The statement after the THEN statement is a GOTO label.

GOTO labels must be alphanumeric ended by a colon and at least one space.


002 * Example of the conditional statements

003 if <<c2>> = "" then go done

004 list <<c2>>

005 done: * end of paragraph


Loops allow the user to loop the same set of commands over and over again until a conditional statement exits out of the loop. If there is no conditional statement, then the loop processes indefinitely.


002 * Example of a loop

003 loop

004 list md

005 if <<Are you done? (Y/N)>> = "Y" then go done

006 repeat

007 done: * end of paragraph


Data stacking allows the paragraph to stack information into the input buffer for use in the next command processed. Paragraphs use the same syntax as BASIC.


002 * stacked data example

003 data temp

004 copy md "listfile"

Paragraphs are not likely to be found on the older Multi-value systems based on R83. Paragraphs can be found in the new systems: D3, AP, Universe, and Unidata.

Paragraphs are very handy for those simple tasks that would normally not warrant the need for a BASIC program. It also allows non-programmers to create simple commands to help automate groups of TCL commands.