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

Home » Public Forums » archive » recursive 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
recursive functions? [message #21526] Thu, 31 August 2000 08:48 Go to next message
Nando Iavarone is currently offline  Nando Iavarone
Messages: 48
Registered: December 1998
Member
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hi all,
<br>I wrote a recursive function, but something does not work.
<br>The example reported is the skeleton of the function.
<p>In this version:
<p> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
function recFun, var1, var2
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print, var1, var2
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
err = recFun($
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
string(var1)+'.Prrrr', $
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp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; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return, err
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
end;
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<p>if the source file is recFun.pro,
<br>IDL shows:
<p>ENVI> .compile recFun
<br>% Compiled module: RECFUN.
<br>% Compiled module: RECFUNTEST.
<br>ENVI> err=recFunTest(12,15)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 12.Prrrr&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
15.Prrrr
<br>% Variable is undefined: RECFUN.
<br>% Execution halted at:&nbsp; RECFUN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& ;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& ;nbsp;&nbsp;
5
<br>&nbsp; /home/nando/InPhase/procedureDiProva/recFun.pro
<br> %&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;
RECFUNTEST&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 19
<br>&nbsp; /home/nando/InPhase/procedureDiProva/recFun.pro
<br> %&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;
$MAIN$
<br>ENVI>
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<p>If the file is modified as:
<p> &nbsp;&nbsp;&nbsp;&nbsp;&n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;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
return, err
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
end;
<br>&nbsp;
<p>the recursive function works.
<p>Am I missing something in the first case?
<br>Why it does not work?
<p>Thank you.
<pre>--&nbsp;
Nando Iavarone
Advanced Computer System - SPACE DIVISION
via Lazzaro Belli, 23
00040&nbsp; Frascati - RM
Tel: +39-6-944091 (switchboard)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 9440968 (direct)
E-mail:&nbsp;
&nbsp;&nbsp;&nbsp; f.iavarone@acsys.it
&nbsp;&nbsp;&nbsp; FrdndVrn@altavista.net</pre>
&nbsp;</html>
Re: recursive functions? [message #21596 is a reply to message #21526] Fri, 01 September 2000 02:57 Go to previous message
Nando Iavarone is currently offline  Nando Iavarone
Messages: 48
Registered: December 1998
Member
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
David Fanning wrote:
<blockquote TYPE=CITE>....I have to
<br>warn you, however, that with this line your test program
<br>will run forever!</blockquote>
I know, I know.
<br>It was to show the skeleton of the original function without to show
it entirely.
<br>I found already the solution on manual and on........ your www page&nbsp;
:o(
<br>Maybe as first resource&nbsp; I'd search on your web pages.
<p>Have you idea of the difference between the two versions of the test
code?
<br>I think it is important to understand how IDL works.
<p>Bye.
<pre></pre>

<pre>--&nbsp;
Nando Iavarone
Advanced Computer System - SPACE DIVISION
via Lazzaro Belli, 23
00040&nbsp; Frascati - RM
Tel: +39-6-944091 (switchboard)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 9440968 (direct)
E-mail:&nbsp;
&nbsp;&nbsp;&nbsp; f.iavarone@acsys.it
&nbsp;&nbsp;&nbsp; FrdndVrn@altavista.net</pre>
&nbsp;</html>
Re: recursive functions? [message #21621 is a reply to message #21526] Thu, 31 August 2000 09:30 Go to previous message
Nando Iavarone is currently offline  Nando Iavarone
Messages: 48
Registered: December 1998
Member
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Nando Iavarone wrote:
<blockquote TYPE=CITE>I don't remember well, but 5.3 would have a mechanism
in compiling to avoid this.</blockquote>

<p><br>I look better in the manual and:
<br>there exist the FORWARD_FUNCTION statement.
<p>I answer me. Ohhhh.
<p>The problem about the difference about the two code fragment remains?
<br>Why don't they work in the same manner?
<p>Cheers,
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Nando.
<pre>--&nbsp;
Nando Iavarone
Advanced Computer System - SPACE DIVISION
via Lazzaro Belli, 23
00040&nbsp; Frascati - RM
Tel: +39-6-944091 (switchboard)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 9440968 (direct)
E-mail:&nbsp;
&nbsp;&nbsp;&nbsp; f.iavarone@acsys.it
&nbsp;&nbsp;&nbsp; FrdndVrn@altavista.net</pre>
&nbsp;</html>
Re: recursive functions? [message #21622 is a reply to message #21526] Thu, 31 August 2000 08:37 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Nando Iavarone (f.iavarone@acsys.it) writes:
>
> I don't remember well, but 5.3 would have a mechanism in compiling to
> avoid this.
> Is it true?

Forward_Function RecFun

As the first line in RecFun will do it. I have to
warn you, however, that with this line your test program
will run forever! You might want to give this some thought. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: recursive functions? [message #21624 is a reply to message #21526] Thu, 31 August 2000 09:08 Go to previous message
Nando Iavarone is currently offline  Nando Iavarone
Messages: 48
Registered: December 1998
Member
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Nando Iavarone wrote:
<blockquote TYPE=CITE>ENVI> .compile recFun
<br>% Compiled module: RECFUN.
<br>% Compiled module: RECFUNTEST.
<br>ENVI> err=recFunTest(12,15)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 12.Prrrr&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
15.Prrrr
<br>% Variable is undefined: RECFUN.
<br>% Execution halted at:&nbsp; RECFUN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& ;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& ;nbsp;&nbsp;
5
<br>&nbsp; /home/nando/InPhase/procedureDiProva/recFun.pro
<br> %&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;
RECFUNTEST&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 19
<br>&nbsp; /home/nando/InPhase/procedureDiProva/recFun.pro
<br> %&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;
$MAIN$
<br>ENVI>
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;</blockquote>
it seems that the first time IDL 'compile' recFun function,
<br>it consider recFun (in the code it is a function) a variable and on
run it does not find it.
<br>if I recompile the source, recFun is now in the table of the functions
and it works.
<br>as a workaround I compile the source twice and it works, but I don't
like this.
<br>I am sure there is something I have not considered.
<p>I don't remember well, but 5.3 would have a mechanism in compiling to
avoid this.
<br>Is it true?
<br>Oh oh........ but I am working with 5.2 (to use ENVI 3.2).
<p>Bye.
<br>&nbsp;
<pre>--&nbsp;
Nando Iavarone
Advanced Computer System - SPACE DIVISION
via Lazzaro Belli, 23
00040&nbsp; Frascati - RM
Tel: +39-6-944091 (switchboard)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 9440968 (direct)
E-mail:&nbsp;
&nbsp;&nbsp;&nbsp; f.iavarone@acsys.it
&nbsp;&nbsp;&nbsp; FrdndVrn@altavista.net</pre>
&nbsp;</html>
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: opening and display large file
Next Topic: what happened to time/date functions?

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

Current Time: Thu Oct 09 08:28:48 PDT 2025

Total time taken to generate the page: 1.20099 seconds