Re: Value of variables in programs after first call



Brian wrote:
I am trying to find out if COBOL program varialbes retain their values
in Working Storage after the first call to the program. For Example,
if I have PROGA calling PROGB (which are compiled separately), on the
first call to PROGB, the value clauses set the initial values in
working storage. Are the values in working storage retained so they
are available on the second call to PROGB, or are they undefined?

Thank you,

Brian

If the construct you mean is:

CALL 'SUBPROG' USING XYZ

and

PROCEDURE DIVISION USING ABC

Then the values in WS do, in fact, remain in their last state between calls.
For example:

Calling program:

CALL 'ABC' USING XYZ.
CALL 'ABC' USING XYZ.
CALL 'ABC' USING XYZ.

The called program:

01 PARAM PIC 9 VALUE 0.

PROCEDURE DIVISION USING BLAH.

ADD 1 TO PARAM.

GOBACK.

On the first entry to the subprogram, PARAM contains 0. On exit from the
first call, PARAM contains 1.

On the second entry, PARAM is still 1, on exit PARAM is 2.

And so on.


.



Relevant Pages

  • Re: Value of variables in programs after first call
    ... in Working Storage after the first call to the program. ... if I have PROGA calling PROGB, ... the value clauses set the initial values in working storage. ... Without a CANCEL or IS INITIAL then the W-S is how it ...
    (comp.lang.cobol)
  • Value of variables in programs after first call
    ... I am trying to find out if COBOL program varialbes retain their values ... in Working Storage after the first call to the program. ... if I have PROGA calling PROGB, ... the value clauses set the initial values in ...
    (comp.lang.cobol)