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

Home » Public Forums » archive » static variable mayhem
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 variable mayhem [message #11770 is a reply to message #11685] Wed, 13 May 1998 00:00 Go to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
Theo Brauers wrote:
>
> Hi:
>
> you may try the following:
>
> FUNCTION foo, x
> COMMON foo, called
> ; look if called is defined, what ever value it has!
> IF n_elements(called) EQ 0 THEN BEGIN
> ; define called
> called=1
> RETURN, x-1
> ENDIF
> RETURN, x+1
> END
>
> I hope it solves your problem.
> Theo
>

... but be careful when you want to assign variables of different length
to the common block (i.e. arrays or structures). Then you'll have to use
pointers, i.e.

commons,pinfo

if (n_elements(pinfo) eq 0) then pinfo=ptr_new()

if (ptr_valid(pinfo)) then *pinfo=data




------------------------------------------------------------ -------
Dr. Martin Schultz
Department for Earth&Planetary Sciences, Harvard University
109 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA

phone: (617)-496-8318
fax : (617)-495-4551

e-mail: mgs@io.harvard.edu
Internet-homepage: http://www-as.harvard.edu/people/staff/mgs/
------------------------------------------------------------ -------
[Message index]
 
Read Message
Read Message
Previous Topic: Re: IDL 5.1 & ActiveX
Next Topic: Re: IDLSPEC

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

Current Time: Wed Oct 08 19:25:50 PDT 2025

Total time taken to generate the page: 0.00462 seconds