Chapter 14. Functions; Syntax; Functions And Subroutines - IBM SC34-5764-01 Manual

Cics transaction server for vse/esa
Table of Contents

Advertisement

Chapter 14. Functions

A function is an internal, built-in, or external routine that returns a single result string. (A subroutine is a
function that is an internal, built-in, or external routine that may or may not return a result and that is called
with the CALL instruction.)

Syntax

A function call is a term in an expression that calls a routine that carries out some procedures and
returns a string. This string replaces the function call in the continuing evaluation of the expression. You
can include function calls to internal and external routines in an expression anywhere that a data term
(such as a string) would be valid, using the notation:
,
function_name(
The function_name is a literal string or a single symbol, which is taken to be a constant.
There can be up to an implementation-defined maximum number of expressions, separated by commas,
between the parentheses. In VM, the implementation maximum is up to 20 expressions. These
expressions are called the arguments to the function. Each argument expression may include further
function calls.
Note that the left parenthesis must be adjacent to the name of the function, with no blank in between, or
the construct is not recognized as a function call. (A blank operator would be assumed at this point
instead.) Only a comment (which has no effect) can appear between the name and the left parenthesis.
The arguments are evaluated in turn from left to right and the resulting strings are all then passed to the
function. This then runs some operation (usually dependent on the argument strings passed, though
arguments are not mandatory) and eventually returns a single character string. This string is then included
in the original expression just as though the entire function reference had been replaced by the name of a
variable whose value is that returned data.
For example, the function SUBSTR is built-in to the language processor (see page 192) and could be
used as:
N1='abcdefghijk'
Z1='Part of N1 is: 'substr(N1,2,7)
/* Sets Z1 to 'Part of N1 is: bcdefgh' */
A function may have a variable number of arguments. You need to specify only those that are required.
For example, SUBSTR('ABCDEF',4) would return DEF.

Functions and Subroutines

The function calling mechanism is identical with that for subroutines. The only difference between functions
and subroutines is that functions must return data, whereas subroutines need not.
The following types of routines can be called as functions:
Internal
If the routine name exists as a label in the program, the current processing status is saved, so that
it is later possible to return to the point of invocation to resume execution. Control is then passed
to the first label in the program that matches the name. As with a routine called by the CALL
© Copyright IBM Corp. 1992, 2009
)
expression
171

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Rexx

Table of Contents