Re: calling a function in herself [message #20882 is a reply to message #20881] |
Mon, 31 July 2000 00:00   |
Martin Schultz
Messages: 515 Registered: August 1997
|
Senior Member |
|
|
"J�rg Schliwa" wrote:
>
> OF course it has to be in the example:
> Function H_Wahl,a,b,Steig=steig,Abstand=abstand
>
> so that was not the error!
>
> J�rg Schliwa <joerg.schliwa@ewetel.net> schrieb in im Newsbeitrag:
> 8m4c9b$3h9$1@ac1.ewetel.de...
>> Hy to all!
>>
>> I have a file with the main-procedure and some functions in it. When I'm
> in
>> the function e.g h_wahl I want to call the function h_wahl again. Is that
>> possible? When I compile the file, the expression h_wahl is not known in
>> h_wahl.
>>
>> e.g.
>> ;procedure rasterung.pro
>>
>> Function H_Wahl(a,b,Steig=steig,Abstand=abstand)
>> If Keyword_Set(abstand) Then .....
>>
>> If Keyword_Set(steig) Then Begin
>> ...
>> return, H_Wahl(c,d,/abstand)
>> Endif
>> End
>>
>> pro rasterung...
>>
>> Any suggestions?
>>
>> Thanks in advance,
>> J�rg Schliwa
>>
>>
Here is a really simpl eexample:
--------------------------------
function recursive, count
print,'count = ',count
if count lt 10 then count = recursive(count+1)
return, count
end
; main
print,'End result = ',recursive(0L)
end
-----------------------------------
save as recursive.pro and start this with .r recursive, and it will run.
In you rcase,
you might need to include a FORWARD_FUNCTION statement as the first line
in h_wahl. That
shoul dhelp.
Regards,
Martin
--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ Dr. Martin Schultz Max-Planck-Institut fuer Meteorologie [[
[[ Bundesstr. 55, 20146 Hamburg [[
[[ phone: +49 40 41173-308 [[
[[ fax: +49 40 41173-298 [[
[[ martin.schultz@dkrz.de [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
|
|
|