REXX Tips & Tricks, Version 2.80


Inf-HTML [About][Toc][Index] 0.9b (c) 1995 Peter Childs


The keyword instruction PROCEDURE



Be aware that any routine declared with <PROCEDURE only allows access to 
the global variables it knows to all called routines (see also The keyword 
instruction EXPOSE). 
Example: 

 
  i = 4
  k = 3
  j = 2
  say "Value of i at program start is " || i
  say "Now calling MyProc1 from the main function ..."
  call MyProc1
  say " Value of i after call of MyProc1 is " || i

  say "Now calling MyProc2 from the main function ..."
  call MyProc2
  say "Value of i after call of MyProc2 is " || i
exit 0

MyProc1: PROCEDURE expose k j
  say " Now calling MyProc2 from within the function myProc1 ..."
  i = 0
  call MyProc2
RETURN

MyProc2: PROCEDURE expose i
  say "  MyProg2 starts ..."
  say "   Value of i in MyProc 2 is " || i

                        /* This is the global variable i if MyProc2   */
                        /* is called from the main function -- but:   */
                        /* This is a local variable if MyProc2 is     */
                        /* called from MyProc1!                       */
  i = i + 2

  say "   Value of i in MyProc 2 changed to " || i
  say "  ... MyProg2 ends."
RETURN


  
Note:  If you want to use a label with <CALL and <SIGNAL you cannot use 
       the keyword <PROCEDURE! 
   

Inf-HTML End Run - Successful