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