[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

recursive functions?



Hi all,
I wrote a recursive function, but something does not work.
The example reported is the skeleton of the function.

In this version:

                    function recFun, var1, var2
                         print, var1, var2
                         err = recFun($
                         string(var1)+'.Prrrr', $
                         string(var2)+'.Prrrr')
                         return, 0
                    end;
 

                    function recFunTest, var1, var2
                        err = recFun($
                           string(var1)+'.Prrrr', $
                           string(var2)+'.Prrrr')
                        return, err
                    end;
 
 
 

if the source file is recFun.pro,
IDL shows:

ENVI> .compile recFun
% Compiled module: RECFUN.
% Compiled module: RECFUNTEST.
ENVI> err=recFunTest(12,15)
      12.Prrrr      15.Prrrr
% Variable is undefined: RECFUN.
% Execution halted at:  RECFUN              5
  /home/nando/InPhase/procedureDiProva/recFun.pro
%                       RECFUNTEST         19
  /home/nando/InPhase/procedureDiProva/recFun.pro
%                       $MAIN$
ENVI>
 
 
 

If the file is modified as:

                        function recFunTest, var1, var2

                            print, var1, var2
                            err = recFuntest($
                                string(var1)+'.Prrrr', $
                                string(var2)+'.Prrrr')
 
                            return, err
                        end;
 

the recursive function works.

Am I missing something in the first case?
Why it does not work?

Thank you.

-- 
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