The Question is:
How do I identify the routine_name parameter in a call to LBR$GET_INDEX from
COBOL? The sub-program identified by routine_name never gets called. I can get
this to work in C and Fortran.
The Answer is :
COBOL doesn't handle the concept of a procedure variable as easily as
some other languages. Your action routine must be compiled separately
from the module that references it. Declare the action routine
reference in working storage as external. For example:
01 ACTION-ROUTINE PIC S9(9) COMP VALUE EXTERNAL THE-ACTION-ROUTINE.
(tip - use different names for the routine and reference so you can
easily distinguish them under DEBUG)
Now pass your reference name by immediate value:
CALL 'LBR$GET_INDEX' USING BY REFERENCE LBR-INDEX
BY REFERENCE INDEX-NUM
BY VALUE ACTION-ROUTINE
BY DESCRIPTOR MATCH-KEY
Obviously the argument list defined in the LINKAGE SECTION of
ACTION-ROUTINE must match what's passed by LBR$GET_INDEX. Since the
COBOL compiler has no idea what you're doing, it cannot perform any
checks. Start with a simple routine that verifies you're getting
something sensible. Don't forget to return a status!