Re: inter subprogram in initial state, but only sometimes
- From: "James J. Gavan" <jgavandeletethis@xxxxxxx>
- Date: Wed, 28 Dec 2005 23:02:09 GMT
Frank Swarbrick wrote:
I know that if you put the "IS INITIAL" clause on the PROGRAM-ID statement it will reload all of working-storage every time the program is called. I also know that the calling program can CANCEL the called program in order to remove it from memory, thus causing a "new" version of the program to be loaded the next time it is called. But is there a way for the CALLED program to basically cancel itself once it is complete? In other words, I want the sub-program to sometimes be entered in it's last used state and sometimes in it's initial state. But only the sub-program itself needs to know when it wants to do one and when it wants to do the other. Of course it could pass something back to the caller instructing the caller to cancel it, but the caller is not forced to obey this.
I don't actually have a need for this, but it did get me thinking...
Following up on Richard's comments made me have a re-look at above.
What you didn't say of course is that you would like this feature to be COBOL 85 compliant - to Hell with OO ! :-). So just following up on your *desperate* attempt to get back to a thread on COBOL - some wild suggestions.
First obviously ignore 'INITIAL STATE'
Now send a flag to the Called Program telling it InitialState or StoredState and a return code Finished or NotFinished on the iterative cycle.
01 InitialValues. 05 a pic 9(?) value ? 05 b pic x(?) value ?
How many fields do you want to hold ? Above could be all zeroes and spaces; alternatively they could hold initial values. Whatever; the above values would be used when receiving your InitialState flag.
01 StoredValues. -----> keep these in a file/table - see below 05 aa pic 9(?) value ? 05 bb pic x(?) value ?
So having started with your InitialValues, and if the called program is not to be finalised, put values into StoredValues. Next call with the
StoredState flag set True, and you use StoredValues instead.
Want to get fancy using an OO buzzword - Persistent Objects - store the results of StoredValues in one Relative File record or a DB Table for retrieval on subsequent calls.
Needless to say, the above is no big deal for OO. You can create one instance of a class, and providing you don't terminate it, (finalize/destroy/auto garbage collection), those Stored Values are *still* in Working Storage based on the last invoke which referenced and changed any of them. (Bear in mind any variables contained in a method Local-Storage are lost when you exit the method. Methods *always* start in an initial state). Further you could create additional 'sets' by having further instances of the same class which would all start in their InitialState, whether or not you were using zeroes or non zero values etc.
Jimmy
.
- Follow-Ups:
- Re: inter subprogram in initial state, but only sometimes
- From: Pete Dashwood
- Re: inter subprogram in initial state, but only sometimes
- References:
- inter subprogram in initial state, but only sometimes
- From: Frank Swarbrick
- inter subprogram in initial state, but only sometimes
- Prev by Date: Re: inter subprogram in initial state, but only sometimes
- Next by Date: Re: religion
- Previous by thread: Re: inter subprogram in initial state, but only sometimes
- Next by thread: Re: inter subprogram in initial state, but only sometimes
- Index(es):