CIGAL Reference Manual, Chapter 2 (Commands): DEFINE
usage: define 'namestring' 'string2'
The DEFINE command is used to assign a character string to a single word in such a way that the word can be used as a shorthand for the character string. The substitution is done by a pre-processor, before the command line is passed to the parser routine that breaks the line into separate arguments and checks for syntax. This means that the original command line need not be a syntactically valid CIGAL command by itself, provided that it is syntactically correct after the DEFINEd words have been substituted by the pre-processor. For example,
define 'pi' '3.1415926' define 'even' '0 - 62 - 1' ; EVEN has 5 args for LIST cmd define 'odd' '-1 - 62 - 1' ; ODD " " " " " " list jfile even ; list even pages w/ line numbers list jfile odd ; " odd " " " " a = pi*b**2 ; calculate area from radius
In the above examples, each DEFINE name is a single word and the substitutions simply replace one string for another. However, the DEFINE command can also be used to create simple pseudo-functions by declaring the NAMESTRING with arguments. Arguments are declared as single letters within parentheses in the NAMESTRING, and will be used wherever those single letters appear in the substitution string, STRING2. For example,
define 'front(a)' 'list a -1 - 62 - 1' define 'func(x,y)' '(sin(2*x)+cos(y/2))/(x+y)' define 'redlut' '^0' ; define alias for red lookup table front(jfile) --> list jfile -1 - 62 - 1 front jfile --> list jfile -1 - 62 - 1 red = func(123,red) --> ^0 = (sin(2*123)+cos(^0/2))/(123+^0)
Note: The parentheses on pseudo-function arguments are optional when you use the function (but are required in the DEFINE command). Also, you can use defined names within other defined strings or as arguments to pseudo- functions, EXCEPT in cases where a define must not result in a substitution that includes the original defined name because this would result in an infinite recursive loop.
DECLARE(2), PREPROCESSOR(1), SYNTAX(1)