Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calling a function from itself
Message
From
31/03/2006 13:55:16
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
31/03/2006 13:40:42
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01109601
Message ID:
01109613
Views:
22
>>Here is my code:
>>FUNCTION GenerateLawLabelBarcode
>>LPARAMETERS ...
>> .......
>> GenerateLawLabelBarcode(....)
>> return ....
>>ENDFUNC
>>
>>I have an error saying that a file "GenerateLawLabelBarcode" does not exist.
>>
>>Please, help.
>
>You can't do that! A function or procedure can't call itself.

In addition to the other relies you got ("yes, you can!"), recursion (i.e., a function calling itself) can in fact be very useful. For example, the following pseudocode will process all files in a directory, including subdirectories:
Function ProcessFiles()
For every file in directory (including directories)
  If it is a file
    Do something
  If it is a directory
    Invoke ProcessFiles() for the subdirectory
Next
Now, try to do the same without recursion. It should be possible, but much more complicated.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform