IBM Books

Administration and Programming Guide for OS/400

Executing REXX Programs

With the REXX language environment you can execute both in-line REXX programs or external REXX programs. An in-line REXX program is a REXX program that has the source of the REXX program in the macro. An external REXX program has the source of the REXX program in a external file.

To execute an in-line REXX program:

Define a function that uses the REXX (DTW_REXX) language environment and contains the REXX code in the function.

Example: A function that contains a in-line REXX program

%function(DTW_REXX) helloWorld() {
        SAY 'Hello World'
%}

To run an external REXX program:

Define a function that uses the REXX (DTW_REXX) language environment and includes a path to the REXX program that is to be run in an EXEC statement.

Example: A function that contains an EXEC statement pointing to a the external program

%function(DTW_REXX) externalHelloWorld() {        
%EXEC{ /QSYS.LIB/REXX.LIB/REXXSRC.FILE/HELLOWORLD.MBR%}       
%}

You can shorten the path to the program if you use the EXEC_PATH configuration variable to define paths to directories that contain programs. See EXEC_PATH to learn how to define the EXEC_PATH configuration variable.

Restriction: If you are running OS/400 V3R2 or V3R7 and a REXX program uses the SAY REXX instruction to write to stdout, then insert 12 blanks at the start of the string. For example:

SAY '           STARTOFDATA'   

The 12 blanks are ignored, but if they are not inserted, unpredictable results might occur.


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