IBM Books

Net.Data Reference Guide

EXEC Block or Statement

Purpose

The EXEC statement or block specifies an external program to execute when a variable referenced or a function is called.

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

Syntax

The EXEC statement, used in the DEFINE block:

                +-----------------------+
                V                       |
>>-%exec-----"----+--------------------++--"-------------------><
                  +-string-------------+
                  +-variable reference-+
                  +-function call------+
 

The EXEC block, used in the FUNCTION block:

                +-----------------------+
                V                       |
>>-%exec-----{----+-string-------------++---}------------------><
                  +-variable reference-+
                  +-function call------+
 

Parameters

%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.

name

An alphabetic or numeric string that begins with a an alphabetic character or underscore and contains any combination of alphabetic, numeric, or underscore characters.

string

Any sequence of alphabetic and numeric characters and punctuation except a tabulator, new line character, or a space.

variable reference

Returns the value of a previously defined 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 previously defined FUNCTION blocks with specified arguments. See Function call (@) for syntax and examples.

Context

Can be found in these contexts:

Restrictions

Can contain these elements:

Examples

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

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

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

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


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