Re: Changing common variable definition [message #2557] |
Tue, 26 July 1994 06:42 |
thompson
Messages: 584 Registered: August 1991
|
Senior Member |
|
|
larkum@optolab.unibe.ch (Matthew Larkum) writes:
> ... I don't want to have
> different common variable definitions in different modules, I
> simply want to be able to add a variable to all modules, recompile
> and proceed. ...
> The only way I know to continue at the moment is to exit and
> restart. This happens running IDL for windows and PV-Wave 4.01
> on a Sun workstation.
> I'm sure there's something I don't understand, but I can't find
> anything about it in the manual or the FAQ.
No, you understand it correctly. One thing I can suggest, if you want to be
able to add variables to common blocks after they're defined, is to encapsulate
your variables into an anonymous structure. You could then redefine this
structure (as long as it's anonymous) to your heart's content.
The release notes for IDL 3.6 says that you can now nest anonymous structures.
Hurray!!!
Bill Thompson
|
|
|
Re: Changing common variable definition [message #2558 is a reply to message #2557] |
Tue, 26 July 1994 06:35  |
tai
Messages: 14 Registered: June 1994
|
Junior Member |
|
|
Matthew Larkum (larkum@optolab.unibe.ch) wrote:
: Works fine. Then I say, "Wait a minute. I forgot. I also need
: a variable 'z'. Fine, make the globals.pro file:
: common my_vars, x, y, z
: run test
: % Attempt to extend previously defined common: MY_VARS
: At: /$DIRECTORY/globals
: The only way I know to continue at the moment is to exit and
: restart. This happens running IDL for windows and PV-Wave 4.01
: on a Sun workstation.
Yes, I noticed that too. I don't know of any other way to extend it
than to exit and restart. I remember I couldn't figure it out for the
longest time.
Alan
|
|
|
Re: Changing common variable definition [message #2559 is a reply to message #2558] |
Tue, 26 July 1994 06:20  |
andy
Messages: 31 Registered: November 1993
|
Member |
|
|
In article <312ne0$1ug@aragorn.unibe.ch>, larkum@optolab.unibe.ch (Matthew Larkum) writes:
> Hi,
> If I write some routines that share the line say:
> common my_vars, x, y
> and then add a variable:
> common my_vars, x, y, z
> and recompile, I get an error:
> % Attemp to extend previously defined common: MY_VARS
> Is there any way to redefine a common variable?
> Thanks,
> Matthew
> larkum@optolab.unibe.ch
>
I believe that in order to redefine a COMMON block one must make the
appropriate changes, exit IDL, and then re-enter IDL and run the procedure.
--
,__o Andrew F. Loughe (Mail Code 971)
-\_<, NASA Goddard Space Flight Center phone: (301) 286-5899
(*)/'(*) Greenbelt, MD 20771 email: andy.loughe@gsfc.nasa.gov
|
|
|
Re: Changing common variable definition [message #2560 is a reply to message #2559] |
Tue, 26 July 1994 06:17  |
larkum
Messages: 21 Registered: May 1993
|
Junior Member |
|
|
In article fnd@reznor.larc.nasa.gov, tai@rockola.larc.nasa.gov (Alan Tai) writes:
> Matthew Larkum (larkum@optolab.unibe.ch) wrote:
> : common my_vars, x, y
> : and then add a variable:
> : common my_vars, x, y, z
> : and recompile, I get an error:
> : % Attemp to extend previously defined common: MY_VARS
> : Is there any way to redefine a common variable?
>
> No, your common block definitions must all be the same (ala Fortran).
> If you're using IDL version 3.6, you can just do the following:
>
> common my_vars, x, y
> ...
> common my_vars
>
> If you're using an earlier version, my suggestion is to go with an
> @include_file.
>
> main program:
> @globals.pro
> ...
> @globals.pro
>
> globals.pro:
> common my_vars, x, y
>
> Hope this helps.
No, this isn't quite what I was getting at. I don't want to have
different common variable definitions in different modules, I
simply want to be able to add a variable to all modules, recompile
and proceed. Taking your example I tried:
pro subroutine
@globals.pro
print, 'This is the subroutine'
end
pro test
@globals.pro
print, 'This is the main routine'
end
The globals.pro file was initially:
common my_vars, x, y
Works fine. Then I say, "Wait a minute. I forgot. I also need
a variable 'z'. Fine, make the globals.pro file:
common my_vars, x, y, z
run test
% Attempt to extend previously defined common: MY_VARS
At: /$DIRECTORY/globals
The only way I know to continue at the moment is to exit and
restart. This happens running IDL for windows and PV-Wave 4.01
on a Sun workstation.
I'm sure there's something I don't understand, but I can't find
anything about it in the manual or the FAQ.
Thanks again,
Matthew
larkum@optolab.unibe.ch
|
|
|
Re: Changing common variable definition [message #2561 is a reply to message #2560] |
Tue, 26 July 1994 04:52  |
tai
Messages: 14 Registered: June 1994
|
Junior Member |
|
|
Matthew Larkum (larkum@optolab.unibe.ch) wrote:
: common my_vars, x, y
: and then add a variable:
: common my_vars, x, y, z
: and recompile, I get an error:
: % Attemp to extend previously defined common: MY_VARS
: Is there any way to redefine a common variable?
No, your common block definitions must all be the same (ala Fortran).
If you're using IDL version 3.6, you can just do the following:
common my_vars, x, y
...
common my_vars
If you're using an earlier version, my suggestion is to go with an
@include_file.
main program:
@globals.pro
...
@globals.pro
globals.pro:
common my_vars, x, y
Hope this helps.
Alan
|
|
|