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

Home » Public Forums » archive » Re: Function compiles, but get message as if it's not
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
Re: Function compiles, but get message as if it's not [message #41074] Wed, 22 September 2004 14:25
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
Mark Hadfield wrote:
>
> If you do "taco, parameters, /keywords" OR "result = taco(...)",
> IDL will search for a file "taco.pro" in your path and compile
> everything until it finds a routine (procedure OR function)
> called taco. Anything following that won't be compiled.
>

And now I see David has already written that up in

http://www.dfanning.com/tips/namefiles.html

But what I am wondering now is this: Does anyone know *why* IDL does
it this way? Why doesn't it just compile the whole file

--
Mark Hadfield "Ka puwaha te tai nei, Hoea tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
Re: Function compiles, but get message as if it's not [message #41086 is a reply to message #41074] Wed, 22 September 2004 08:40 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Pesto writes:

> And a special thanks to David Fanning for his excellent book, IDL
> Programming Techniques.
> It got me started with IDL programming quickly, unlike the RSI
> documentation.

Oh, well, it better have. :-)

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http:/www.dfanning.com/
Phone: 970-221-0438, IDL Book Orders: 1-888-461-0155
Re: Function compiles, but get message as if it's not [message #41087 is a reply to message #41086] Wed, 22 September 2004 08:37 Go to previous message
Pesto is currently offline  Pesto
Messages: 2
Registered: September 2004
Junior Member
Thanks to all. With some pro/function manipulations I seem to have resolved
the problem.

And a special thanks to David Fanning for his excellent book, IDL
Programming Techniques.
It got me started with IDL programming quickly, unlike the RSI
documentation.

Chris Wieland AKA Pesto

"Pesto" <dellaenterprises[removethis]@prodigy.net> wrote in message
news:rP6dnQNDn6NhLM3cRVn-rQ@giganews.com...
> Hello,
> I'm having a problem with an IDL program. Within the program I have a
> function that converts a number into a string in the return value. The
first
> time I compile and run the program (everything is in a single .PRO file),
it
> stops with an error when the call to that function it encountered. It
claims
> the function is not recognized. I stop the program, recompile, and upon
> rerunning the program, it does not stop with that error, but executes the
> function as expected. Is there some required sequence of functions and
> procedures within the program? Or is there something else I don't
understand
> (I'm pretty new at IDL programming)?
> Thanks for any clues.
> Chris
>
>
Re: Function compiles, but get message as if it's not [message #41094 is a reply to message #41087] Wed, 22 September 2004 00:25 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Pesto writes:

> I'm having a problem with an IDL program. Within the program I have a
> function that converts a number into a string in the return value. The first
> time I compile and run the program (everything is in a single .PRO file), it
> stops with an error when the call to that function it encountered. It claims
> the function is not recognized. I stop the program, recompile, and upon
> rerunning the program, it does not stop with that error, but executes the
> function as expected. Is there some required sequence of functions and
> procedures within the program? Or is there something else I don't understand
> (I'm pretty new at IDL programming)?

Here is an article you might want to read:

http://www.dfanning.com/tips/namefiles.html

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http:/www.dfanning.com/
Phone: 970-221-0438, IDL Book Orders: 1-888-461-0155
Re: Function compiles, but get message as if it's not [message #41095 is a reply to message #41094] Tue, 21 September 2004 20:12 Go to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
Benjamin Hornberger wrote:

> If you do ".compile taco", IDL will search for a file "taco.pro"
> in your path and compile it, recognizing all procedures and functions
> in the file.
>
> If you do "taco, parameters, /keywords", IDL will search for a file
> "taco.pro" in your path and compile everything until it finds a
> PROCEDURE taco. Anything following that won't be compiled. A FUNCTION
> taco won't be recognized.
>
> If you do "result = taco(...)", IDL will search for a file
> "taco.pro" in your path and compile everything until if finds
> a FUNCTION taco. Anything following that won't be compiled. A
> PROCEDURE taco won't be recognized.
>

I believe the 2nd and 3rd paragraphs are not quite correct. They should
be rewritten as:

If you do "taco, parameters, /keywords" OR "result = taco(...)",
IDL will search for a file "taco.pro" in your path and compile
everything until it finds a routine (procedure OR function)
called taco. Anything following that won't be compiled.

To illustrate this, created a file on your path called taco.pro, and
add the following lines

function taco
end

pro taco
end

Now invoke the procedure "taco". IDL prints

IDL> taco
% Compiled module: TACO.
% Attempt to call undefined procedure/function: 'TACO'.
% Execution halted at: $MAIN$

It has compiled the function and then quit, even though it was looking
for a procedure.

> So, make sure the function / procedure which has the same name as the
> file is the last one in the file. This will normally be your "main"
> function / procedure. If other functions / procedures are called
> (needed) exclusively by that "main" one, put them into the same file,
> but above. If any function / procedure might be needed more often, put
> them into their own file.

All good advice, irrespective of the details.

--
Mark Hadfield "Ka puwaha te tai nei, Hoea tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
Re: Function compiles, but get message as if it's not [message #41096 is a reply to message #41095] Tue, 21 September 2004 16:58 Go to previous message
Benjamin Hornberger is currently offline  Benjamin Hornberger
Messages: 258
Registered: March 2004
Senior Member
If you do ".compile taco", IDL will search for a file "taco.pro" in your
path and compile it, recognizing all procedures and functions in the file.

If you do "taco, parameters, /keywords", IDL will search for a file
"taco.pro" in your path and compile everything until it finds a
PROCEDURE taco. Anything following that won't be compiled. A FUNCTION
taco won't be recognized.

If you do "result = taco(...)", IDL will search for a file "taco.pro" in
your path and compile everything until if finds a FUNCTION taco.
Anything following that won't be compiled. A PROCEDURE taco won't be
recognized.

So, make sure the function / procedure which has the same name as the
file is the last one in the file. This will normally be your "main"
function / procedure. If other functions / procedures are called
(needed) exclusively by that "main" one, put them into the same file,
but above. If any function / procedure might be needed more often, put
them into their own file.

Good luck,
Benjamin


Pesto wrote:
> Hello,
> I'm having a problem with an IDL program. Within the program I have a
> function that converts a number into a string in the return value. The first
> time I compile and run the program (everything is in a single .PRO file), it
> stops with an error when the call to that function it encountered. It claims
> the function is not recognized. I stop the program, recompile, and upon
> rerunning the program, it does not stop with that error, but executes the
> function as expected. Is there some required sequence of functions and
> procedures within the program? Or is there something else I don't understand
> (I'm pretty new at IDL programming)?
> Thanks for any clues.
> Chris
>
>
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: fuzzy c-means clustering IDL code
Next Topic: open HTTP links from a widget

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

Current Time: Wed Oct 08 19:59:37 PDT 2025

Total time taken to generate the page: 0.00465 seconds