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
  • Verified Answer

    This is managed JVM code.

    You can use PARAMS in the procedure division header of a procedural COBOL program but the parameters in the calling program must be passed by value.

     

           working-storage section.
    	   01 param1   pic x  value "1".
    	   01 param2   pic x  value "2".
    	   01 param3   pic x  value "3".
           procedure division.
    
    		   call "prog2" using by value param1, param2 param3
           ...
           
           program-id. prog2.
           procedure division using params myparams as string occurs any.
    
    	   perform varying s1 as string thru myparams
    	      display s1
    	   end-perform
    
    
Reply
  • Verified Answer

    This is managed JVM code.

    You can use PARAMS in the procedure division header of a procedural COBOL program but the parameters in the calling program must be passed by value.

     

           working-storage section.
    	   01 param1   pic x  value "1".
    	   01 param2   pic x  value "2".
    	   01 param3   pic x  value "3".
           procedure division.
    
    		   call "prog2" using by value param1, param2 param3
           ...
           
           program-id. prog2.
           procedure division using params myparams as string occurs any.
    
    	   perform varying s1 as string thru myparams
    	      display s1
    	   end-perform
    
    
Children
No Data