recursive functions? [message #21526] |
Thu, 31 August 2000 08:48  |
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>
function recFun, var1, var2
<br>
print, var1, var2
<br>
err = recFun($
<br>
string(var1)+'.Prrrr', $
<br>
string(var2)+'.Prrrr')
<br>
return, 0
<br>
end;
<br>
<p>
function recFunTest, var1, var2
<br>
err = recFun($
<br>
string(var1)+'.Prrrr', $
<br>
string(var2)+'.Prrrr')
<br>
return, err
<br>
end;
<br>
<br>
<br>
<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> 12.Prrrr
15.Prrrr
<br>% Variable is undefined: RECFUN.
<br>% Execution halted at: RECFUN & ;nbsp; & ;nbsp;
5
<br> /home/nando/InPhase/procedureDiProva/recFun.pro
<br> %   ;   ;   ;
RECFUNTEST 19
<br> /home/nando/InPhase/procedureDiProva/recFun.pro
<br> %   ;   ;   ;
$MAIN$
<br>ENVI>
<br>
<br>
<br>
<p>If the file is modified as:
<p>
function recFunTest, var1, var2
<p>
print, var1, var2
<br>
err = recFuntest($
<br>
string(var1)+'.Prrrr', $
<br>
string(var2)+'.Prrrr')
<br>
<br>
return, err
<br>
end;
<br>
<p>the recursive function works.
<p>Am I missing something in the first case?
<br>Why it does not work?
<p>Thank you.
<pre>--
Nando Iavarone
Advanced Computer System - SPACE DIVISION
via Lazzaro Belli, 23
00040 Frascati - RM
Tel: +39-6-944091 (switchboard)
9440968 (direct)
E-mail:
f.iavarone@acsys.it
FrdndVrn@altavista.net</pre>
</html>
|
|
|