EXEC Block or Statement

Purpose

Specifies an external program to execute when a variable is referenced or a function is called.

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 your operating system 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.

Authorization Tip: Ensure that the user ID under which Net.Data executes has access rights to any files referenced by the EXEC statement or block. See the section on specifying Web server access rights to Net.Data files in the configuration chapter of Net.Data Administration and Programming Guide for your operating system for more information.

The EXEC statement and block are used in two different contexts and have different syntax, depending where they are used. Use the EXEC statement in the DEFINE block, and use the EXEC block in the FUNCTION block.

Syntax

The EXEC statement syntax when used in the DEFINE block:

                 .-------------------------.
                 V                         |
>>-%EXEC------"----+-string-------------+--+---"---------------><
                   +-variable reference-+
                   '-function call------'
 

The EXEC block syntax when used in the FUNCTION block:

                 .-------------------------.
                 V                         |
>>-%EXEC------{----+-string-------------+--+---%}--------------><
                   +-variable reference-+
                   '-function call------'
 

Values

%EXEC
The keyword that specifies the name of an external program to be executed when a variable is referenced or when a function is called. When Net.Data encounters a variable reference that is defined in an EXEC statement, it processes what the EXEC statement declares for the variable.

string
Any sequence of alphabetic and numeric characters and punctuation. If the string appears within double quotes, the new-line character is not allowed.

variable reference
Returns the value of a variable and is specified with $ and (). For example: if VAR='abc', then $(VAR) returns the value 'abc'. See Variable Reference for syntax information.

function call
Invokes one or more FUNCTION or MACRO_FUNCTION blocks, or a Net.Data built-in function with specified arguments. See Function Call (@) for syntax and examples.

Context

The EXEC block or statement can be found in these contexts:

Restrictions

The EXEC block or statement can contain these elements:

The following Net.Data-provided language environments support the EXEC statement:

Examples

Example 1: Executable file referenced by a variable

%DEFINE mycall = %EXEC "MYEXEC.EXE $(empno)"
 
%HTML (report){
<p>Here is the report you requested:
<hr>$(mycall)
%}

This example executes MYEXEC.EXE on every reference to the variable, mycall.

Example 2: Executable file referenced by a function

%FUNCTION(DTW_REXX) my_rexx_pgm(INOUT a, b, IN c, INOUT d){
   %EXEC{ mypgm.cmd this is a test %}
%}

This example executes mypgm.cmd when the function my_rexx_pgm is called.


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