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?

What does your manual say about this ?

on the first call to PROGB,
the value clauses set the initial values in working storage.

That is not quite how it works. The value clauses set how the compiler
creates the memory block that is loaded when the program is first
called. The value clauses are not 'executed', they are not code.

Are the values in working storage retained so they
are available on the second call to PROGB, or are they undefined?

They are defined, but what actually happens depends on whether PROGB
has been CANCELed or marked as IS INITIAL. In the case of these then
the W-S is as initially loaded ie with the values specified in the
value clauses. Without a CANCEL or IS INITIAL then the W-S is how it
was left by the previous iteration. ie if the program during the first
call changed the value of a variable then that value will still be set
on the second call.

.



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, ... PROCEDURE DIVISION USING ABC ... On the first entry to the subprogram, PARAM contains 0. ...
    (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)