[an error occurred while processing this directive]

HP OpenVMS Systems

ask the wizard
Content starts here

COBOL Routine Names and Librarian?

» close window

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.
 
Thanks,
 
Glen
 


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
                                 GIVING RETURN-STATUS.
 
    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!

answer written or last revised on ( 9-JUN-2004 )

» close window