Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sorting a grid column with negative numbers
Message
 
To
25/04/2001 18:57:12
Elyse Pomerantz
Dynamic Data Concepts, Inc.
Brooklyn, New York, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00499559
Message ID:
00499938
Views:
23
>>>>>In my grid class I allow users to sort on up to 3 columns by clicking in the headers. I convert all the fields to characters in order to string them together. For example, the code might look something like:
>>>>>INDEX ON CharField1+STR(NumField2) TAG temp
>>>>>The problem is that if the numeric field contains negative numbers, they don't sort properly by value. How can I get the numbers to sort correctly and yet index on multiple fields?
>>>>>
>>>>>Thanks,
>>>>
>>>>Elyse,
>>>>
>>>>Try this:
INDEX ON CharField1 + BINTOC(NumField2) TAG temp
This will work, however, only if the numeric field has no decimal places.
>>>
>>>Thanks, but the numeric fields do have decimals.
>>
>>OK, I think we got it this time. Use BINTOC() and multiply the field value by 10 ^ n, where n equals the number of decimal places. The upper limit would be 9 decimal places (1 billion). Will this work?
>
>Bingo! This seems to work beautifully, and quite cleanly, too. Thanks to everyone who offered their suggestions.

Terrific! This was one of those problems that was so interesting, I had to find a solution. However, as a side note, probably the upper limit to it is probably a numeric field that has a total length, excluding the decimal point of 10.

Thanks for sticking with me.< s >
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform