Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Recursive functions
Message
From
01/10/2001 10:57:21
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
01/10/2001 10:48:22
Chris Berthold
The COMMERCIAL Group, Inc.
Sarasota, Florida, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00562407
Message ID:
00562556
Views:
12
>>hi all,
>>i have an algorithm problem which needs input from you guys, any help would be >greatly appreciated!
>>suppose i have table1 to hold inventory items (finished products). and table2 >to hold items (finished, semi-finished, raw materials) in relation to items in >table1. as in this figure:
>
>>table1 table2 table2
>>------ ------ ------
>>item1 ----> item1.1
>>item1.2 ----> item1.2.1
>>item1.3
>
>>item2 ----> item2.1
>>item2.2
>>item2.3
>
>>wherein item1 is a finished product, which consists of item1.1 (raw material), >item1.2 (semi-finished product) and item1.3 (raw material). since item1.2 is a >semi-finished product, i have to look for its pre-defined details (like i did >for item1) in table 2 also (which is item1.2.1, a raw material).
>
>>im thinking of having a recursive function but does vfp allow this? if so, how >would i do it?
>
>Yes a recursive function will work. We use one to do a bottom level explosion on Bills of Materials like your talking about. The trick is to ensure that your variables are defined in the right scope, and after each function you need to return the cursor back to its original position. there is one detail. functions are recursive to 99 levels. if you need to go deeper than you'll have to some while loops to keep the explosions going.

99? In VFP, DO can be nested 128 levels, with or without recursion. Of course, it may happen that in your testing you already had used up 29 levels, before trying a recursive function.
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