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
  • I believe that PARAMS can only be specified in the procedure division header of a method and not in a procedural program but I am awaiting confirmation on this.

    The parameter array must be that of a managed type so to pass in a variable number of pic x fields you would receive this as an array of strings. 

     

           working-storage section.
    	   01 param1   pic x  value "1".
    	   01 param2   pic x  value "2".
    	   01 param3   pic x  value "3".
           procedure division.
    
    		   declare myobj = new MyClass
    		   invoke myobj::mymethod(param1, param2, param3)
    	...	   
           class-id MyClass.
           method-id mymethod.
           procedure division using params data-fld-nms as string occurs any.
               perform varying s1 as string thru data-fld-nms
    				  display s1
    		   end-perform
           		   
    
Reply
  • I believe that PARAMS can only be specified in the procedure division header of a method and not in a procedural program but I am awaiting confirmation on this.

    The parameter array must be that of a managed type so to pass in a variable number of pic x fields you would receive this as an array of strings. 

     

           working-storage section.
    	   01 param1   pic x  value "1".
    	   01 param2   pic x  value "2".
    	   01 param3   pic x  value "3".
           procedure division.
    
    		   declare myobj = new MyClass
    		   invoke myobj::mymethod(param1, param2, param3)
    	...	   
           class-id MyClass.
           method-id mymethod.
           procedure division using params data-fld-nms as string occurs any.
               perform varying s1 as string thru data-fld-nms
    				  display s1
    		   end-perform
           		   
    
Children
No Data