Re: Linking multiple files... [message #31505] |
Tue, 23 July 2002 08:26 |
Pavel A. Romashkin
Messages: 531 Registered: November 2000
|
Senior Member |
|
|
Assuming a fairly late version of IDL, you can specify
Compile_opt IDL2
inside your routines, which will force strict definitions of arrays
using [ ]. This way, ambiguity of using ( ) is avoided and you routines
will execute every time.
HTH,
Pavel
Bob wrote:
>
> I open both of these files up in IDL and tell it to "Compile All". In
> the event log it says:
>
> % Compiled module: FINDROOTS
> % Compiled module: PRINT_TO_FILE
>
> So, I run the procedure PRINT_TO_FILE. I immediately get the following
> error:
> % Variable is undefined: FINDROOTS
|
|
|
Re: Linking multiple files... [message #31512 is a reply to message #31505] |
Mon, 22 July 2002 19:35  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
squad@hotmail.com (Bob) writes:
> Hey everyone... maybe I'm just really dumb, but for some reason I
> can't get IDL to properly link several files together. What I mean by
> link is the following:
>
> --- In one file, I have a function called "FINDROOTS" which finds the
> roots of a quadratic equation (Function FindRoots, a, b, c).
>
> --- In one file I have a procedure "PRINT_TO_FILE", which calls
> FindRoots with a very short list of different a's and b's and c's, and
> then outputs it to a text file.
David's solution is the correct one. The quick and dirty solution is
to put:
forward_function findroots
within PRINT_TO_FILE, before the first reference to FINDROOTS() is
made.
The problem is that IDL doesn't know whether you are referring to an
function or an array, since both are accessed using the () notation.
Since you didn't keep FINDROOTS in its own self-named file, IDL won't
know about it and assume that references to FINDROOTS are array
references. The above hint helps IDL decide.
Good luck,
Craig
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|
Re: Linking multiple files... [message #31513 is a reply to message #31512] |
Mon, 22 July 2002 17:20  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Bob (squad@hotmail.com) writes:
> Hey everyone... maybe I'm just really dumb, but for some reason I
> can't get IDL to properly link several files together. What I mean by
> link is the following:
>
> --- In one file, I have a function called "FINDROOTS" which finds the
> roots of a quadratic equation (Function FindRoots, a, b, c).
>
> --- In one file I have a procedure "PRINT_TO_FILE", which calls
> FindRoots with a very short list of different a's and b's and c's, and
> then outputs it to a text file.
>
> I open both of these files up in IDL and tell it to "Compile All". In
> the event log it says:
>
> % Compiled module: FINDROOTS
> % Compiled module: PRINT_TO_FILE
>
> So, I run the procedure PRINT_TO_FILE. I immediately get the following
> error:
> % Variable is undefined: FINDROOTS
>
> The strange thing is that if I recompile both yet again (without any
> changes), the error goes away and everything is fine. However, this is
> incredibly annoying. Also, my problem isn't *this simple*, and this
> happens again and again and again .......
>
> Any help would be greatly appreciated.
Put FINDROOTS in a file named "findroots.pro". Put
PRINT_TO_FILE in a file named "print_to_file.pro".
Make sure both of those modules are the *last* module
in their respective files. Put the files somewhere in
your !PATH.
Now you don't have to compile anything and everything
will magically "work". :-)
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|