Variable number of arguments to a cobol program

Is there a way to create a COBOL sub-program (procedural) that accepts a variable number of arguments similar to the "C" va_start or "Java" ... or "C#" params keyword.

 

Thanks

 

Parents
  • Are you using managed or native COBOL?
    PARAMS only applies to managed - if you want to make some arguments optional in native COBOL you can use the PARAMCOUNTCHECK directive:

    a.cbl:
    working-storage section.
    01 s1 pic x(32) value "sausages".
    01 s2 pic x(32) value "mashed potato".
    01 s3 pic x(32) value "baked beans".

    procedure division.

    call "b" using "sausages" "mash"

    call "b" using "baked beans"

    stop run.

    b.cbl:
    $set PARAMCOUNTCHECK
    linkage section.
    01 s1 pic x(32).
    01 s2 pic x(32).

    procedure division using s1 s2.
    display s1

    if address of s2 not = null
    display s2
    end-if

    goback
    .
Reply
  • Are you using managed or native COBOL?
    PARAMS only applies to managed - if you want to make some arguments optional in native COBOL you can use the PARAMCOUNTCHECK directive:

    a.cbl:
    working-storage section.
    01 s1 pic x(32) value "sausages".
    01 s2 pic x(32) value "mashed potato".
    01 s3 pic x(32) value "baked beans".

    procedure division.

    call "b" using "sausages" "mash"

    call "b" using "baked beans"

    stop run.

    b.cbl:
    $set PARAMCOUNTCHECK
    linkage section.
    01 s1 pic x(32).
    01 s2 pic x(32).

    procedure division using s1 s2.
    display s1

    if address of s2 not = null
    display s2
    end-if

    goback
    .
Children
No Data