Previous Topic

Next Topic

Book Contents

Book Index

%%$FUNC

%%$FUNC is an AutoEdit function that enables the creation of user-defined functions. You can only use the %%$FUNC function as part of an AutoEdit %%SET statement.

The syntax for such use of the %%$FUNC function is

%%SET output_char_string = %%$FUNC func_name input_char_string

In its operation, it is equivalent to using assembler language to issue the following CALL instruction

CALL func_name,(input_char_string,output_char_string)

In this instruction

The AutoEdit processor passes these parameters as variable-length strings. Each string consists of a half-word binary length field followed by the string itself. The func_name program must return the output string in the same format, as illustrated in the example below.

The source string can contain AutoEdit variables. If it does, these variables are resolved before the function is activated.

The maximum length of the source string, after resolving any AutoEdit variables, is 240 characters.

The maximum length of the result string is also 240 characters.

Neither the source string nor the result string can contain non-displayable characters.

You can use AutoEdit simulation to test your program module. For more information, see M2: Perform an AutoEdit Simulation.

Note: You can define your func_name program module as resident. A resident program module is loaded once, kept in the storage, and entered by means of either the CALL instruction or a LINK instruction. If you want to do this, the program module must comply with both the following conditions:

Example

The user has a multiply function that is performed by a module named MULT.

The user’s JCL contains the following AutoEdit statements:

%%SET %%A = 20

%%SET %%B = 30

%%SET %%C = %%$FUNC MULT %%A %%B

The last %%SET statement causes the Control-M monitor to call the MULT module as follows (using assembler notation):

CALL MULT,(PRM1,PRM2)

The PRM1 and PRM2 parameters are passed to MULT in the following format:

PRM1 DC H'5'

      DC C'20 30'

PRM2 DC H'0'

     DC CL240' '

The MULT program returns results by updating the value of the second parameter, PRM2, as follows:

PRM2 DC H'3'

     DC C'600'

The result is that the AutoEdit variable %%C is assigned a character value of 600.

Parent Topic

Functions