IBM Books

Reference

Executable Variables


AIX HP-UX Linux OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X X

Executable variables allow you to invoke other programs from a variable reference using the executable variable feature. An executable variable is defined in a Net.Data macro using the EXEC language element. For more information about the EXEC language element, see EXEC Block or Statement.

When Net.Data encounters an executable variable in a macro, it looks for the referenced executable program using the following method:

  1. It searches the EXEC_PATH in the Net.Data initialization file. See the configuration chapter in Net.Data Administration and Programming Guide for more information about EXEC_PATH.
  2. If Net.Data does not locate the program, it searches the directories defined by the system. If it locates the executable program, Net.Data runs the program.

Example 1: An executable variable definition

%DEFINE runit=%exec "testProg"

The variable runit is defined to execute the executable program testProg; runit becomes an executable variable.

Net.Data runs the executable program when it encounters a executable variable reference in a Net.Data macro. For example, the program testProg is executed when a executable variable reference is made to the variable runit in a Net.Data macro.

A simple method is to reference an executable variable from another variable definition. Example 2 demonstrates this method. The variable date is defined as an executable variable and dateRpt is then defined as a variable reference, that contains the executable variable.

Example 2: An executable variable as a variable reference

%DEFINE date=%exec "date"
%DEFINE dateRpt="Today is $(date)"

When Net.Data resolves the variable reference $(dateRpt), Net.Data searches for the executable date, runs the program, and returns:

Today is Tue 11-07-1995

An executable variable is never set to the value of the output of the executable program it calls. Using the previous example, the value of date is null. If you use it in a DTW_ASSIGN function call to assign its value to another variable, the value of the new variable after the assignment is null also. The only purpose of an executable variable is to invoke the program it defines.

You can also pass parameters to the program to be executed by specifying them with the program name on the variable definition.

Example 3: Executable variables with parameters

%DEFINE mph=%exec "calcMPH $(distance) $(time)" 

The values of distance and time are passed to the program calcMPH.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]