Using Binding Files with REXX Procedures
If your REXX program contains any internal subroutines that are
introduced by
procedurestatements, it is important for you to remember that language bindings you load with APILOAD in the main routine will not automatically be visible inside these subroutines. This is illustrated by the following example:
/* SLOWSAY EXEC */
Call APILOAD 'VMREXMTR'
Call APILOAD 'VMREXPRO'
x = saywithwait('This is a test')
return 0
saywithwait: procedure
parse arg what
say what
/* VMREXPRO bindings are invisible here, so the */
/* following WILL NOT WORK... 'ThreadDelay' will */
/* be undefined */
interval = 1000
call csl 'ThreadDelay cslrc cslre interval'
return 0
If your procedure needs to use bindings loaded with APILOAD, you
have three choices:
- Load the bindings in your mainline program and use EXPOSE to expose
the specific constants and procedure names your procedure will need.
For example:
/* SLOWSAY EXEC */ Call APILOAD 'VMREXMTR' Call APILOAD 'VMREXPRO' x = saywithwait('This is a test') return 0 saywithwait: procedure expose, ThreadDelay parse arg what say what interval = 1000 call csl 'ThreadDelay cslrc cslre interval' return 0
- Avoid using the REXX
procedure
statement altogether; just use a label. For example:/* SLOWSAY EXEC */ Call APILOAD 'VMREXMTR' Call APILOAD 'VMREXPRO' x = saywithwait('This is a test') return 0 saywithwait: /* no procedure statement */ parse arg what say what interval = 1000 call csl 'ThreadDelay cslrc cslre interval' return 0
- If performance considerations will permit it, load the bindings
inside your procedure. For example:
/* SLOWSAY EXEC */ x = saywithwait('This is a test') return 0 saywithwait: procedure call APILOAD 'VMREXMTR' call APILOAD 'VMREXPRO' parse arg what say what interval = 1000 call csl 'ThreadDelay cslrc cslre interval' return 0