|
>Date: Tue, 14 Nov 2000 13:09:02 -0800 >From: Joel Fritz <JFritz@sharperimage.com> > >What is the lifetime of a a local static variable? > ... >.... 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. Joel, that's the way it's documented to work (see the entry for the STATIC keyword in the reference). " ... it is _not_ reinitialized again, even if reinitialization occurs for global definitions as part of normal cycle processing." Your best bet is either to move the static variable into global definitions, or set up some other static variable in globals that says to initialize subproc static. D inzSubpStatic s n inz(*on) P subp b D staticVar s 10a static inz('x') C if inzSubpStatic C eval inzSubpStatic = *off C reset staticVar C endif P e By the way, don't forget that each module has its own LR. It's not the program that ends with LR on, it's the main procedure in the module. Barbara Morris +--- | 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.