Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Message thread
Message
From
28/05/2004 13:43:10
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00907956
Message ID:
00908245
Views:
27
>>However, for a message thread, if you intend to become as popular as this place... you better go recursive and build these keys on your selected data, not on your underlying table, or don't build any keys, just copy records into an empty cursor one by one, going recursively over your original data.
>>
>>Or go recursively and assign them ordinal numbers as you go, then index by this ordinal number. That would be the simplest.
>
>Thanks for confirming my thoughts Dragan. After sleeping on the issue I came to the same conclusion while driving to work (I had not read UT at that time<s>).
>Again thank you for your analysis and advise.

This is roughly (I had to remove some special-case lines) the code I've found works the fastest so far for recursion. Order the table on nParent. Stek[] array and stekptr variable need to be private to the calling procedure - it keeps the record to return to. The skeleton for this was written in 1989, I'd probably do it much shorter now and use properties instead. Or probably I already did, but can't find the better version anymore :).
procedure scan_1(_key)
local _nkey
StekPtr=StekPtr+1
DIME stek(StekPtr)
=SEEK(_key)
SCAN WHILE nParent=_key
	stek(StekPtr)=RECNO()
	_nkey=nMessageId
* do something here with the current record
	this.scan_1 (_nkey)
	GO stek(StekPtr)
ENDSCAN
StekPtr=StekPtr-1

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform