This is for mainframe OS/390 COBOL.
We have a subroutine (SUB1) that was initially written to receive one 132 byte parameter and print a line of output. Several hundred programs were using it.
With laser printing capable of printing more characters, this routine was changed to handle either 132 or 198 bytes. To do this they added a second parameter with the length value.
They did not want to change all existing mainframe programs to have two parameters so an assembler routine was written. It was named SUB1 and the origininal SUB1 was renamed to SUB2. The assembler routine can determine if a second parameter is being used. SUB1 always calls SUB2 with two parameters. If only one parameter is received by SUB1, it calls SUB2 with a second parameter value of 132. If two parameters are received by SUB1, it calls SUB2 with those two parameters.
I would like to get rid of the assembler program. How can I get a COBOL program to determine if it received a second parameter?
I have tried to use ADDRESS OF. I can check the ADDRESS OF the second parameter and if it is NULL, I only have one parameter. But once I make a call with two parameters, there seems to always be an address associated with parameter 2. This needs to work if I call with one parameter, then call with two, and then call with one.
I cannot change the subroutine to require two parameters because there are a couple hundred programs already using it with one parameter. I want this change to be transparent to any of the existing root programs.
Any ideas?
We have a subroutine (SUB1) that was initially written to receive one 132 byte parameter and print a line of output. Several hundred programs were using it.
With laser printing capable of printing more characters, this routine was changed to handle either 132 or 198 bytes. To do this they added a second parameter with the length value.
They did not want to change all existing mainframe programs to have two parameters so an assembler routine was written. It was named SUB1 and the origininal SUB1 was renamed to SUB2. The assembler routine can determine if a second parameter is being used. SUB1 always calls SUB2 with two parameters. If only one parameter is received by SUB1, it calls SUB2 with a second parameter value of 132. If two parameters are received by SUB1, it calls SUB2 with those two parameters.
I would like to get rid of the assembler program. How can I get a COBOL program to determine if it received a second parameter?
I have tried to use ADDRESS OF. I can check the ADDRESS OF the second parameter and if it is NULL, I only have one parameter. But once I make a call with two parameters, there seems to always be an address associated with parameter 2. This needs to work if I call with one parameter, then call with two, and then call with one.
I cannot change the subroutine to require two parameters because there are a couple hundred programs already using it with one parameter. I want this change to be transparent to any of the existing root programs.
Any ideas?