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