Previous Page | Next Page

Language Reference

LINK Statement

LINK( label ) ;
statements ;
label:statements ;
RETURN ;

The LINK statement provides a way of calling a group of statements as if they were defined as a subroutine. Like the GOTO statement, when the LINK statement is executed, the program jumps immediately to the statement with the given label and begin executing statements from that point. However, unlike the GOTO statement, when the program executes a RETURN statement, the program returns to the statement that immediately follows the LINK statement.

The LINK statement can be used only inside modules and DO groups. LINK statements can be nested within other LINK statements to any level. A RETURN statement without a LINK statement is executed the same as the STOP statement.

Instead of using a LINK statement, you can define a module and call the module by using a RUN statement.

An example that uses the LINK statement follows:

start a;
   x=1;
   y=2;
   link sum1; /* go to label; execute until return stmt */
   print z;
   stop;
   sum1:
      z=x+y;
   return;
finish a;

run a;

Figure 23.153 Result of Linking to a Group of Statements
z
3

Previous Page | Next Page | Top of Page