Was this helpful?
System Macros
Built-in System Macros are as follows. Parameter are specifiers with one ($) or two dollar signs ($$), as discussed in Parameter Prescan.
{begintrap}
Executed before the query is submitted.
{continuetrap}
Executed after the query executes.
{define; $$t; $$r}
Defines a macro.
Special processing (see page Special {define} Processing) occurs on the template (t) part.
{dump}
Dumps all macros in {rawdefine} form.
{dump; $$n}
Returns the value of the macros that match n. It uses the same algorithm as {remove}.
{editor}
Defines the online editor to use in the \edit command.
UNIX/Linux: To change the default vi editor to the ed editor, enter:
{define;{editor};/bin/ed}
which invokes the ed editor in response to the \e command.
Windows: To change the default editor to Notepad, enter:
{define;{editor};notepad.exe}
which invokes "notepad" in response to the \e command.
VMS: To change the default (EDT) editor to the TPU editor, enter:
{define;{editor};edit/tpu}
which invokes the TPU editor in response to the \e command.
{endtrap}
Executed after the query is submitted, but before the query executes.
{errornumber}
By default returns the generic error number. If II_EMBED_SET is set to dbmserror, the DBMS error is returned instead.
{ifeq; $$a; $$b; $t; $f}
Compares the numbers a and b. If the numbers match, the returned value is t; otherwise, the returned value is f.
{ifgt; $$a; $$b; $t; $f}
Compares the numbers a and b. If a is greater than b the returned value is t; otherwise the returned value is f.
{ifsame; $$a; $$b; $t; $f}
Compares the strings a and b. If the strings match, the returned value is t; otherwise the returned value is f.
{rawdefine; $$t; $$r}
Is another form of {define}, where the special processing does not take place. Rawdefine is rarely used. Seen when listing macros with the \list command, because the DBMS Server converts all {define} statements into their corresponding {rawdefine} form.
{read $$s}
Types s and reads a line from the terminal. The typed line acts as the replacement text for the macro.
{readcount}
Contains the number of characters read in the most recent {read} or {readdefine}.
A Ctrl+Z (VMS) or Ctrl+D (UNIX) (end of file) becomes -1; a single newline becomes zero; and so forth, so that the number accurately reflects printing characters.
{readdefine; $$n; $$s}
Types s and reads a line, but it further creates a macro called n, which is set to the line entered at the terminal. This lets you set aside a line for further processing.
The replacement text for {readdefine} is the count of the number of characters in the line. {readcount} is set to this number.
{remove}
Removes all macros.
{remove; $$n}
Removes all macros beginning with name $n.
For example, typing:
{define; get part $n; ... }
{define; get emp $x; ... }
defines two macros that start with the word "get".
To remove both "get" macros, type:
{remove; get}
To remove the first macro only, type:
{remove; get part}
{substr; $$b; $$e; $$s}
Returns the part of string s between character positions b and e, numbered from one. If b or e is out of range, it is moved in range as much as possible.
{shell}
Defines the pathname of a shell to use in the \shell command.
{tuplecount}
Is set after every query, but before {continuetrap} is executed, to the number of rows returned by a select or the number of rows changed in an update.
It is not set for some SQL statements (CREATE VIEW, for example). If multiple queries are run at once, it is set to the number of rows that satisfied the last query run.
{type $$s}
Types s onto the terminal.
Last modified date: 01/30/2023