|
Lifetime of ILE static variables by architecture is the lifetime of activation group. For example, for *DFTACTGRP this means until the end of the job. Alexei Pytel Joel Fritz <JFritz@sharperimage.com>@midrange.com on 11/14/2000 03:09:02 PM Please respond to RPG400-L@midrange.com Sent by: owner-rpg400-l@midrange.com To: "RPG400-L@midrange. com (E-mail)" <RPG400-L@midrange.com> cc: Subject: lifetime of a static variable What is the lifetime of a a local static variable? I wrote a little test program that included a static variable defined in a sub procedure. It was supposed to distinguish between the first and second call to the procedure within the test program. My test was static varible > 0. Worked as expected on the first call of the program. On the second call of the program the variable retained its value from the first call. Then I got interested. I wrote a program that printed the value of a static variable defined in a sub procedure. The sub procedure added 1 to the value of the static variable and returned that value. The main program printed the value of the variable assigned the value of the procedure--i.e. eval x = staticvarproc, then print the value of x. On the first call to the main program, the output is 1, on the second call 2, and so forth. The program ends with last record *on and was compiled activation group *caller. I called it from the command line repeatedly. It seems to me that the lifetime of the variable is the lifetime of the activation group since when I sign off and call the program after signing on again, the value goes back to 1 for the first call. Is this the way it ought to work? Seems like static local variables shouldn't outlive the programs to which they are local when the program ends with lr on. +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +--- +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.