Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating a compound index with a descending portion
Message
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01053896
Message ID:
01053985
Views:
22
>>>I have an application that needs a compound index built. The fields are all string fields, but the user would like the second field to be in descending order. Is there a good way to do this in VFP?
>>>
>>>TIA
>>
>>If it's only a matter of displaying them, e.g. in a grid or a browse, and if this can be done with the help of a PRG, then I propose a SELECT-SQL statement, like...
>>
select * from sometable order by 1, 2 desc, 3, 4 into cursor c_temp
>>browse
>
>I wish that was the case, as I thought of that one. But I need it to be part of an index. Thanks anyway.

Okay, another approach that also uses Sergey's chrtran(). Create an extra field that will gonna contain an alternative string. Suppose the field that needs to be shown in descending order is named F2, then the extra field might be named F2A. Ensure that F2A is always updated whenever F2 is updated.
REPLACE F2A WITH CHRTRAN(F2, ;
	"0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz", ;
	"zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210")
The index can then be something like
INDEX ON F1+F2A+F3 TAG whatever
BROWSE
The advantage is that the indexing is simple and speedy.
Groet,
Peter de Valença

Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.
Previous
Reply
Map
View

Click here to load this message in the networking platform