>When using two numeric values for a compound index it is typically better to separate the numbers with a delimiter, ie.
>
> ALLT(STR(field1)) + "-" + ALLT(STR(field2))
>
>Otherwise, your seeks will rarely get you the result you want. Note that the ALLTRIM() is used to reduce the size of the CDX file.
I'm not sure this will work if you start your table with small numbers in the first record. or with an empty table ("start" - the moment when you create an index like this).
As a rule of thumb, I'd never create an index with a character expression of variable width. You actually never know its length in the index file, and you never know when it may overflow the actual width used. Also, trimming will disturb the ordering - you usually need the numbers to behave like numbers, so that 10 comes after 9, and not between 1 and 2.
The result of Str() with only one parameter is also depending on Set Decimals. The solution here may be to index on Str(field1,12,0)+Str(field2,12,0) or on Tran(field1, "99999999999")+Tran(field2, "99999999999"); the downside in all these cases is that any negative numbers will ruin your ordering. Now if you're using sure integers, you'd better check BinToC() function, it's just stuffing an integer into a four byte string suitable for idexing, which does keep the ordering. Try this:
create table btoc (i1 i, i2 i)
for i=1 to 200
insert into btoc (i1, i2) value (rand()*5000-2500, rand()*5000)
endf
inde on bintoc(i1)+bintoc(i2) tag btoc
brow
?len(eval(key(1)))