comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Static Variables in IDL
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Static Variables in IDL [message #5904 is a reply to message #5901] Thu, 14 March 1996 00:00 Go to previous messageGo to previous message
steinhh is currently offline  steinhh
Messages: 260
Registered: June 1994
Senior Member
In article <4i8geg$5fv@vixen.cso.uiuc.edu>, santanu@eehpx22.cen.uiuc.edu (S Bhattacharyya) writes:
|>
|>
|> Pardon me if I appear a bit obtuse, but I am still a little confused. I am
|> under the impression that the common block declaration is equivalent to
|> C's global declaration. What I would like to have is a bit of non re-entrant
|> code in a standalone function (.pro). I want an IDL .pro that does the
|> following::
|>
|> main()
|> {
|> for(;;) non_rEntrant();
|> }
|> non_rEntrant()
|> {
|> static int block=1;
|>
|> if (block == 1){
|> puts("This is executed only once");
|> block=0;
|> }
|> puts("And this is done over and over again");
|> }

pro main
while 1 do non_rEntrant
end

pro non_rEntrant
common non_rEntrant_private_others_keep_off,block

if N_elements(block) eq 0 then block=1 ;; Instead of "static .... =1"

if block eq 1 then begin
print,"This is executed only once"
block = 0
end
print,"And this is done over and over again"
end

This will do what you want. Common blocks are not quite like
global declarations. I can have e.g., a variable called block
in the main program without having a conflict. I can even
have a variable called block at the interactive prompt level,
and still have no conflict.

|> call_procedure,'non_rEntrant'

You'll get speedier programs by using just

non_rEntrant

as in the example above 8-)

Stein Vidar
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL Surface
Next Topic: Re: Widgets - 3.6 -> 4.0 Aaarrrggghhh!!

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 17:24:25 PDT 2025

Total time taken to generate the page: 0.00456 seconds