comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Lost Functions
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Lost Functions [message #10226] Fri, 24 October 1997 00:00 Go to next message
Matthew Hanson is currently offline  Matthew Hanson
Messages: 11
Registered: October 1997
Junior Member
I have been having a very bizaare problem in IDL 5.0 on Solaris 2.6
involving Functions becoming 'lost'.
In my batch file i compile all functions. Output reads as expected:
Compiled Module: MY_FUNCTIONS
Then the batch file calls a main, the main then calls MY_FUNCTION, but
instead of working it says : Unknown Variable: MY_FUNCTION, even though
right above it it says that it is a compiled function. If you type Help
at this point MY_FUNCTION appears as a valid function.
Now here is the even weirder part.
I commented out MY_FUNCTION and put in a STOP. After the program stops
I enter MY_FUNCTION at the command prompt Exactly as it appears in the
script. It works fine. But if i .continue it will fail as before. I
have seen this behavior with several different functions.
Has anyone else experienced this?


--
Matthew Hanson

KTAADN, Inc. Phone: (617)527-0054
1320 Centre Street, Suite 201 Fax: (617)527-9321
Newton, MA 02159

matt@ktaadn.com matth@who.net vroomfogle@worldnet.att.net
Re: Lost Functions [message #10228 is a reply to message #10226] Fri, 24 October 1997 00:00 Go to previous messageGo to next message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
[This followup was also posted to comp.lang.idl-pvwave]

Matthew Hanson (matt@ktaadn.com) writes:

> I have been having a very bizaare problem in IDL 5.0 on Solaris 2.6
> involving Functions becoming 'lost'.
> In my batch file i compile all functions. Output reads as expected:
> Compiled Module: MY_FUNCTIONS
> Then the batch file calls a main, the main then calls MY_FUNCTION, but
> instead of working it says : Unknown Variable: MY_FUNCTION, even though
> right above it it says that it is a compiled function. If you type Help
> at this point MY_FUNCTION appears as a valid function.
> Now here is the even weirder part.
> I commented out MY_FUNCTION and put in a STOP. After the program stops
> I enter MY_FUNCTION at the command prompt Exactly as it appears in the
> script. It works fine. But if i .continue it will fail as before. I
> have seen this behavior with several different functions.
> Has anyone else experienced this?

Of course. :-)

Here is what is happening to you. Somewhere in the list
of procedures and functions that is being compiled *before*
your MY_FUNCTION is compiled is a call to the MY_FUNCTION
function. Since IDL doesn't yet know about the MY_FUNCTION
function, it figures the call:

result = MY_FUNCTION(whatever)

is a subscripted variable and it puts its name on its variable
name list. This list is consulted first before it looks at its
procedure and function list when it is trying to resolve the call.


Most of the time this kind of problem is resolved by having
your programs be compiled automatically when they are needed.
In other words, give your program files the same name as the
procedure or function and let IDL find them when it needs them.

If you absolutely need to compile your programs first, then put
this command on the first line of your batch file:

Forward_Function MY_FUNCTION

Now the name "MY_FUNCTION" will be reserved for the function
and IDL will not get confused.

Cheers,

David

-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Lost Functions [message #10264 is a reply to message #10226] Tue, 04 November 1997 00:00 Go to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
David Fanning wrote:
>
> [This followup was also posted to comp.lang.idl-pvwave]
>
> Matthew Hanson (matt@ktaadn.com) writes:
>
[cut]
> Most of the time this kind of problem is resolved by having
> your programs be compiled automatically when they are needed.
> In other words, give your program files the same name as the
> procedure or function and let IDL find them when it needs them.

let me just add a little note on seperate files vs. "libraries", because
I don't think this is mentioned in the IDL manuals:
It seems as if the automatic compilation of IDL always compiles up to
the
point where it finds the procedure or function with the same name as the
filename. Hence, if you have some functions that are closely related,
and
you don't want them all in seperate files, you have to make sure that
you
call the last one first - or that all your *sub*routines precede your
*main*pro(cedure/gram). I use this for a usage mechanism, so instead of
writing out the usage lines within my procedure, I define a
use_<procname>
procedure and this is called when an error is detected in the parameters
passed.

Also, in this respect, it may be of interest to note that IDL is not
completely
case-insensitive when trying to match a filename with a procedure name.
I once
tried a procedure name test_3D.pro, and IDL did not like it, although
the procedure
is named completely identical. Here is what I got:

% Attempt to call undefined procedure/function: 'TEST_3D'.
% Execution halted at: $MAIN$

Regards,
Martin

------------------------------------------------------------ -------------
Dr. Martin Schultz
Department for Earth&Planetary Sciences, Harvard University
186 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA

phone: (617)-496-8318
fax : (617)-495-9837
Please indicate name and room (186 Pierce) when sending a fax

e-mail: mgs@io.harvard.edu
IDL-homepage: http://www-as.harvard.edu/people/staff/mgs/idl/
------------------------------------------------------------ -------------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: A rant: features vs. programming features
Next Topic: IDL Programming Techniques Course Full

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 10:34:31 PDT 2025

Total time taken to generate the page: 1.19967 seconds