Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calling a function from itself
Message
De
31/03/2006 13:55:16
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
31/03/2006 13:40:42
Jim Winter
Jim Winter Consulting
Hinesburg, Vermont, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01109601
Message ID:
01109613
Vues:
23
>>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)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform