Examples of DEFINE Declarations

The following example declares BLANKIT as a define identifier:

DEFINE BLANKIT = REPLACE POINTER(LINEOUT) BY " " FOR 22 WORDS #

Where BLANKIT appears as an allowable define invocation, it is expanded to the following when the program is compiled:

REPLACE POINTER(LINEOUT) BY " " FOR 22 WORDS #

The following example declares SEC as a define identifier with a formal symbol X:

DEFINE SEC(X) = (1 / COS(X)) # 

If SEC(N) appears as an allowable define invocation, it is expanded to the following when the program is compiled:

1 / COS(N)

The following example declares LENGTH as a define identifier with two formal symbols, X and Y:

DEFINE LENGTH(X,Y) = SQRT((X)**2 + (Y)**2)# 

If LENGTH(3,4) appears as an allowable define invocation, it is expanded to the following when the program is compiled:

SQRT(3**2 + 4**2)

The following define results in a syntax error when it is invoked by passing a semicolon as its parameter. The syntax error occurs because the parameter is not expanded when viewed as part of an <end commentary>:

DEFINE X_STATEMENT (SEP) = BEGIN
                              BEGIN
                              Z := -5
                              END SEP
                              A := 5;
                           END #;