Re: function in function [message #27222 is a reply to message #27127] |
Thu, 11 October 2001 14:14  |
Mark Hadfield
Messages: 783 Registered: May 1995
|
Senior Member |
|
|
From: "Steve Smith<steven_smith>" <nobody@nowhere.com>
>
> I wrote a function in my IDL program which opens a proprietary file format
> and dumps the data into an array, as I had to do it many times, I wrote
this
> as a function. In this function, I find I had to convert fixed-point
binary
> numbers to floats, so I wrote a second function wich does this. it is
called
> within the first function. it all works fine, but when I first start IDL,
and
> compile, the program fails with an undefined reference to the second
function.
> after the second compile, it works fine. I inserted the FORWARD_FUNCTION
> statement in the 1st function, and then the problem went away.
> ...
To avoid these problems, either
* Put each function in a separate .pro file (with name =
<function_name>.pro) and make sure both are on your path.
or if you don't want to call the second function from anywhere but inside
your first function
* Put the first function in a .pro file (name = first_function.pro) then add
the code for your second function BEFORE THIS in the file. In this case it's
best to give the second function a name based on the first function name so
it won't clash with anything else (eg first_function_binary_to_float)
The reason for putting auxiliary functions first is that when IDL is trying
to resolve first_function it searches for first_function.pro then compiles
it, stopping when it has found the code for first_function. Any later code
in the file is ignored.
---
Mark Hadfield
m.hadfield@niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield
National Institute for Water and Atmospheric Research
--
Posted from clam.niwa.cri.nz [202.36.29.1]
via Mailgate.ORG Server - http://www.Mailgate.ORG
|
|
|