Creating an Index on Two Numeric Fields in FoxPro

ID: Q89886

The information in this article applies to:

When an application uses the INDEX command to create an index on two numeric fields, INDEX creates one index on the sum of the two fields rather than an index on the concatenation of the fields.

To change this behavior, use the STR() function to convert each numeric field into a string, concatenate the strings together, and created an index on the resulting string value, as follows:

   INDEX ON STR(num1) + STR(num2) TO <file.idx>

Note that the STR() function pads the beginning of each string with additional space characters. You can use the ALLTRIM() function to remove the spaces.

Additional reference words: FoxDos FoxWin FoxMac 1.00 1.01 1.02 2.00 2.50 2.50a 2.50b 2.50c 2.60 2.60a KBCategory: kbprg KBSubcategory: FxprgTable

Last Reviewed: June 27, 1995