| 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 [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
|
|
|
|