It's tricky, but you can use UDF in the index.
INDEX ON myudf(keyfield) to TEMP_DIR+"\MYINDEX.CDX"
LPARAMETER tcKeyField
....
RETURN PADL(lcNewKey,5)
>hi all,
>
>I have a table with a char type key field, the key can be in any combination of letters and interger.. following is a
sorted example:
>
>1, 1A, 2, 2A, 2B, 10, 10A, B2, B10B, C10, C11A, C12B, D...
>
>
>I have to use the INDEX ON command to set them in a correct order..
>
>my command is:
>
>index on iif(val(keyField)=0, ;
> keyField, ;
> padl(alltrim(str(val(keyField), 10, 0)),4,"0")+substr(keyField,len(allt(str(val(room_num), 10, 0)))+1)) ;
> to TEMP_DIR+"\MYINDEX.CDX"
>
>
>with this line B2 would be larger than B10, but the INDEX ON command does not allow me to write a longer statement, anyway for my user B10 is very rare so it's ok.
>
>My real problem is, if the table already have 2A in it, and I append a record with keyField="2", 2 will be arranged
after 2A.
>
>But when I check my code I should have converted 2 to 0002 and 2A to 0002A, any idea please? Any work around or whatsoever is ok, I just want my table to have a correct order.
>
>Thanks in advance!
>Jimi
--sb--