IBM SC34-5764-01 Manuel d'utilisateur Page 80

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 481
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 79
CALL SUBSTR 'verylongword', 1, 8
a = RESULT /* a is set to 'verylong' */
When deciding whether to write a subroutine or a function, ask yourself the following questions:
v Is a returned value optional? If so, write a subroutine.
v Do I need a value returned as an expression within an instruction? If so, write a function.
The rest of this chapter describes how to write subroutines and functions and finally summarizes the
differences and similarities between the two.
Writing Subroutines and Functions
A subroutine is a series of instructions that a program calls to perform a specific task. The instruction that
calls the subroutine is the CALL instruction. You can use the CALL instruction several times in a program
to call the same subroutine.
When the subroutine ends, it can return control to the instruction that directly follows the subroutine call.
The instruction that returns control is the RETURN instruction.
instruction(s)
EXIT
sub1:
instruction(s)
RETURN
instruction(s)
CALL sub1
A function is a series of instructions that a program calls to perform a specific task and return a value. As
Chapter 5, “Using Functions,” on page 51 describes, a function can be built-in or user-written. Call a
user-written function the same way as a built-in function: specify the function name immediately followed
by parentheses that can contain arguments. There can be no blanks between the function name and the
left parenthesis. The parentheses can contain up to 20 arguments or no arguments at all.
function(argument1, argument2,...)
or
function()
A function requires a return value because the function call generally appears in an expression.
z = function(arguments1, argument2,...)
When the function ends, it can use the RETURN instruction to send back a value to replace the function
call.
Writing Subroutines and Functions
58
CICS TS for VSE/ESA: REXX Guide
Vue de la page 79
1 2 ... 75 76 77 78 79 80 81 82 83 84 85 ... 480 481

Commentaires sur ces manuels

Pas de commentaire