You are here: Automating Analyzer > Procedure Labels

Procedure Labels

Procedure Labels enable the ability to store multiple internal procedures within a single existing procedure (.PRO) file. Physically, this is done by placing Procedure Labels within the .PRO file. There is no limit to the number of Procedure Labels in a procedure.

The intent of Procedure Labels is to provide a simple and effective way to implement complex processes without requiring a large number of separate procedure (.PRO) files to be created and allowing processes to be called as required.

Note: Procedure Labels do not appear in the Overview. They can only be run using a DO command within a procedure or at the command line.

Specifying a Procedure Label within a procedure essentially identifies a sub-procedure. Procedure Labels are called from the body of the main procedure using a Do Procedure command. Procedure Labels can be called conditionally if required.

For example, assume a procedure called TEST.pro which contains some commands for processing a table, as well as additional internal Procedure Labels to be run under specified conditions:

COMMENT

These are the main procedure commands

for procedure TEST

END

 

DO .REFRESH_DATA IF FILEDATE(source)>FILEDATE(data)¿

 

DO .GET_NAME if name=” ”

RETURN

 

PROCEDURE REFRESH_DATA

COMMENT

This is an internal Procedure Label

called REFRESH_DATA

END

. . . commands

. . . commands

. . . commands

RETURN

 

PROCEDURE GET_NAME

COMMENT

This is an internal Procedure Label

called GET_NAME

END

. . . commands

. . . commands

. . . commands

RETURN

All Procedure Labels should be terminated with a Return command (similar to how all Group commands are terminated with an End command). This enables the Procedure Label to return to the calling procedure (or section within it) upon completion of the commands contained with the Procedure Label.

Note: If no Return is specified, encountering another procedure label will act as a Return.

When storing Procedure Labels as part of an existing procedure file, ensure that the main procedure commands appear first in the procedure (as shown in the example above) followed by all of the required Procedure Lables, each ended with a Return Command (for more information see Return).

Ideally, the last line of the main procedure commands will be a Return Command prior to the first Procedure Label (as shown in the example above).

Use the Do Procedure command to call internal Procedure Labels in the form Do X.Y, where X is the .PRO file and Y is the Procedure Label contained within procedure X.

For example:

DO TEST.GET_NAME

would be valid for the sample procedure shown above.

Where the internal Procedure Label is contained within the same PRO file that is currently executing then X should be left empty (i.e. DO .Y).

For example:

DO .GET_NAME

This allows portable renaming of the procedure object itself (such as TEST.pro shown above), without breaking any internal references.

For more information see the Do command.

It is also valid to access procedures from different .PRO objects.

For example, you could have a procedure object called UTILITY (or UTILITY_ if you wanted it hidden from the Overview), that contains various Procedure Labels for a number of common useful sub-procedures including one called CONNECT. Any other procedure could access the CONNECT sub-procedure utility using the syntax Do UTILITY.CONNECT.

Note: The internal Procedure Labels are read from the calling procedure in the order that they appear until the appropriate Procedure Label is encountered. As a result there is a slight performance advantage in placing frequently called Procedure Labels nearer to the start of the procedure (immediately following the main procedure commands).