Welcome | spec | C-PLOT | Support | Users | Contact
 
Contents -> REFERENCE MANUAL -> Built-In Functions and Commands -> Commands For Macros -> Built-In Commands
spec Manual


2.4.4.1. - Built-In Commands



def name string
Defines a macro named name to be string. Each time name occurs on input, it is replaced with string. The definition is made immediately, so the macro can be used later in the same statement block in which it is defined and can be redefined within the same statement block.

Note that the macro definition is made regardless of any surrounding flow control statements, since the enclosing mini-program is not yet completely parsed and is not executing.

rdef name expression
Defines a macro named name to be expression, which is almost always a string constant. Each time name occurs on input, the value expression is substituted. Unlike def, described above, the macro definition is not made until all the encompassing statement blocks are parsed and the resulting mini-program is executed. Consider the following example.
    if (flag == 1)
            rdef plot "onp;offt;lp_plot;ont;plot_res;offp"
    else if (flag == 2)
            rdef plot "splot;onp;offt;lp_plot;plot_res;ont;offp"
    else if (flag == 3)
            rdef plot "onp;plot_res;offp"
    else
            rdef plot "
    
Clearly, it is necessary for the mini-program to be parsed and executed to decide which is the appropriate definition to assign to the plot macro.

prdef
Displays all macro definitions. The displayed definitions are prepended with def name \' and terminated with \' so if saved to a file, the definitions can be read back. (See the standard macro savmac 3.3.4 .)

prdef pattern ...
As above, except only macro names matching pattern are listed, where pattern may contain the metacharacters ? or *.

lsdef
Lists the name and the number of characters in each macro definition.

lsdef pattern ...
As above, except only macro names matching pattern are listed, where pattern may contain the metacharacters ? or *.

undef name ...
Removes the named macros, which can be ordinary macros, macro functions or cdef() macros.

cdef("name", string [, "key" [, flags ]])
Defines parts of chained macros. A chained macro definition is maintained in pieces that can be selectively included to form the complete macro definition. The argument name is the name of the macro. The argument string contains a piece to add to the macro.

The chained macro can have three parts: a beginning, a middle and an end. Pieces included in each of the parts of the macros are sorted lexicographically by the keys when putting together the macro definition. Pieces without a key are placed in the middle in the order in which they were added, but after any middle pieces that include a key.

The key argument allows a piece to be selectively replaced or deleted, and also controls the order in which the piece is placed into the macro definition. The flags argument controls whether the pieces are added to the beginning or to the end of the macro, and also whether the pieces should be selectively included in the definition depending on whether key is the mnemonic of a configured motor or counter.

The bit meanings for flags are as follows:
0x01 - only include if key is a motor mnemonic
0x02 - only include if key is a counter mnemonic
0x10 - place in the beginning part of the macro
0x20 - place in the end part of the macro
If flag is the string "delete", the piece associated with key is deleted from the table. If the name is the null string, the piece associated with key is deleted from all the chained macros. If key is the null string, the flags have no effect.

The cdef() function will remove any existing macro defined using def or rdef. However, the commands lsdef, prdef and undef will function with chained macros.

When spec starts and when the reconfig command is run (or the config macro is invoked), all the chained macros are adjusted for the currently configured motors and counters.

cdef("?")
Lists all the pieces of all the chained macros.

cdef("name", "", "?")
Lists the pieces of the macro named name.


  Top
  Prev | Next