z/OS TSO/E REXX Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


External functions and subroutines, and function packages

z/OS TSO/E REXX Reference
SA32-0972-00

You can write your own external functions and subroutines, which allow you to extend the capabilities of the REXX language. You can write external functions or subroutines that supplement the built-in functions or TSO/E external functions that are provided. You can also write a function to replace one of the functions that is provided. For example, if you want a new substring function that performs differently from the SUBSTR built-in function, you can write your own substring function and name it STRING. Users at your installation can then use the STRING function in their execs.

You can write external functions or subroutines in REXX. You can store the exec containing the function or subroutine in:
  • The same PDS from which the calling exec is loaded
  • An alternative exec library as defined by ALTLIB (TSO/E address space only).
  • A data set that is allocated to SYSEXEC (SYSEXEC is the default load ddname used for storing REXX execs)
  • A data set that is allocated to SYSPROC (TSO/E address space only).

You can also write an external function or subroutine in assembler or a high-level programming language. You can then store the function or subroutine in a load library, which allows for faster access of the function or subroutine. By default, load libraries are searched before any exec libraries, such as SYSEXEC and SYSPROC. The language in which you write the exec must support the system-dependent interfaces that the language processor uses to invoke the function or subroutine.

For faster access of a function or subroutine, and therefore better performance, you can group frequently used external functions and subroutines in function packages. A function package is basically a number of external functions and subroutines that are grouped or packaged together. To include an external function or subroutine in a function package, the function or subroutine must be link-edited into a load module. If you write a function or subroutine as a REXX exec and the exec is interpreted (that is, the TSO/E REXX interpreter executes the exec), you cannot include the function or subroutine in a function package. However, if you write the function or subroutine in REXX and the REXX exec is compiled, you can include the exec in a function package because the compiled exec can be link-edited into a load module. For information about compiled execs, see the appropriate compiler publications.

When the language processor is processing an exec and encounters a function call or a call to a subroutine, the language processor searches the function packages before searching load libraries or exec libraries, such as SYSEXEC and SYSPROC. Search order describes the complete search order.

The topics in this section describe:
  • The system-dependent interfaces that the language processor uses to invoke external functions or subroutines. If you write a function or subroutine in a programming language other than REXX, the language must support the interface.
  • How to define function packages.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014