Re: Common trouble [message #16745] |
Fri, 20 August 1999 00:00 |
Kristian Kjaer
Messages: 58 Registered: June 1998
|
Member |
|
|
Kristian Kjaer (kristian.kjaer@risoe.dk) writes:
> Q1: How do you delete a common block (other than by exiting IDL)?
David Fanning wrote:
< You can't. Once declared, it's there forever.
And the same goes for 'globals' defined by DEFSYSV, I think?
- Kristian
|
|
|
Re: Common trouble [message #16785 is a reply to message #16745] |
Wed, 18 August 1999 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Kristian Kjaer (kristian.kjaer@risoe.dk) writes:
I should really leave this question to the common
block experts... :-)
> Q1: How do you delete a common block (other than by exiting IDL)?
You can't. Once declared, it's there forever. I hear
this may be changing in IDL 5.3.
> Q3: Should commons be avoided altogether in IDL ?
I'll defer. Let's just say they are WAY overused in
widget programs, in my humble opinion. But there is no
question they are useful in certain--I think
limited--situations.
> Q2: Why does this not work (got the same with IDL 5.1 on linux):
One of the rules of common block usage is that common
block variables cannot be arguments of procedures:
IDL> ? common blocks
From the error messages you are getting, I suspect the
parameters are somehow marked as a special "type" when
they come into the procedure that is different from the
type you expect them to be when you load them into common.
But this is pure speculation.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: Common trouble [message #16786 is a reply to message #16785] |
Wed, 18 August 1999 00:00  |
m218003
Messages: 56 Registered: August 1999
|
Member |
|
|
In article <37BA9888.2BD5D060@risoe.dk>,
Kristian Kjaer <kristian.kjaer@risoe.dk> writes:
> Q1: How do you delete a common block (other than by exiting IDL)?
by switching off the computer ;-) Seriously: there is no other way!!!
>
> Q3: Should commons be avoided altogether in IDL ?
there has been a thread about this about two months ago. You might want
to check www.deja.com - we shouldn't start this discussion again ...
>
> Q2: Why does this not work (got the same with IDL 5.1 on linux):
> IDL> .r testcomn
>
> common mycomblock,p,q,r
> ^
> % P is already defined with a conflicting definition.
> At: c:\tasclib.idl\special\testcomn.pro, Line 2
>
>
> ; begin code ----------------
> pro testcomn,p,q,r
> common mycomblock,p,q,r
> return
> end
> ; end code ----------------
>
when idl first encounters a common block definition, it reserves the
variable names for the common block if possible. In your case this is not
doable, because you used the same names as procedure arguments (i guess
you want to initialze them). here is a general outline how you can do this:
pro testcomn,pp,qq,rr
common mycomnblock,p,q,r ; note that the variables are undefined here!
if (n_elements(pp) gt 0 and (n_elements(p) eq 0) then $
p = pp $
else $
message,'P cannot be initialized!'
if (n_elements(qq) gt 0 and (n_elements(q) eq 0) then $
q = qq $
else $
message,'Q cannot be initialized!'
if (n_elements(rr) gt 0 and (n_elements(r) eq 0) then $
r = rr $
else $
message,'R cannot be initialized!'
return
end
Regards,
Martin
--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ Martin Schultz Max-Planck-Institut fuer Meteorologie [[
[[ Bundesstr. 55, 20146 Hamburg [[
[[ phone: +49 40 41173-308 [[
[[ fax: +49 40 441787 [[
[[ martin.schultz@dkrz.de [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
|
|
|