× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: RE: lifetime of a static variable
  • From: Joel Fritz <JFritz@xxxxxxxxxxxxxxxx>
  • Date: Wed, 15 Nov 2000 09:10:55 -0800

If I compile a program actgrp *caller and run it in the default activation
group, the static variable's lifetime is the job.  This leads to what I
thought of as unexpected results.  

The particular thing I was doing was using a static variable as a flag to
differentiate between the first call and succeeding calls to a procedure
defined in the main program.  I know there's other ways to do it; it just
seemed like a reasonable thing to do.  

I wrote a simple program to demonstrate short circuit evaluation of things
ANDed together and wrote a procedure that always returned false.  It had a
static counter that was incremented each time the procedure was called.  If
the counter was greater than 1 the procedure wrote a line to a print file.  

I called the procedure like this:

if alwaystrue AND alwaysfalse AND alwaysfalse

The print file will have the line from alwaysfalse only if it's executed a
second time.  Works as expected the first time, not the way I expected the
second time.  I know better now.    

> -----Original Message-----
> From: Jim Langston [mailto:jimlangston@conexfreight.com]
> Sent: Wednesday, November 15, 2000 8:20 AM
> To: RPG400-L@midrange.com
> Subject: Re: lifetime of a static variable
> 
> 
> If you don't want static variables to retain their values during the
> lifetime of the activation group, just what are you using them for?
> 
> Otherwise, just use "normal" variables.
> 
> Regards,
> 
> Jim Langston
> 
+---
| 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 thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.