anyone has an example of C$CARG usage?

Thanks, Giovanni

  • Suggested Answer



    working-storage section.
       77  okay                     pic x(01).
       01 arg-description.
          02 arg-type pic 9(2) binary.
          02 arg-length pic 9(8) binary.
          02 arg-digit-count pic 9(2) binary.
          02 arg-scale pic s9(2) binary.
    linkage section.

    01 util-1st.
      01 1st-caller pic x(10.
      02 1st-data pic x(20.

    01 util-2nd.
      02 2nd-called pic x(30).
      02 2nd-key pic x(256).
      02 filler pic x(100).
    procedure division using util-1st util-2nd.
    call "C$CARG" using okay, util-2nd, arg-description
    if (okay)
      move "Y".   to argument-is-present
     move "N".   to argument-is-present

    if the named parameter is NOT passed than it crashes with a runtime error due to the missing parameter....
    so the function is somehow useless to understand if this parameter is passed or not...
    regards Giovanni

  • Suggested Answer

    The program will not crash if the passed linkage is incorrect provided (a) you do not compile with the -Za directive and then do not address the missing linkage. You can then use C$NARG to first determine how many linkage parameters are passed and code accordingly.