Tore,
21 fields?
For now I do brute force:
SELECT;
CAST('' AS V(40)) AS vSort, CAST('' AS V(40)) AS vHelp, Cur2.cName AS vNR;
FROM curSource AS Cur1 INTO CURSOR curHelp READWRITE
INDEX ON vSort TAG _vSort ASCENDING
LOCAL ARRAY laOcc(1,1), laLen(1,1)
laOcc(1,1) = -1
SELECT;
MAX(OCCURS('.',vNR));
FROM curHelp INTO ARRAY laOcc
FOR lnloop1 = 0 TO laOcc(1,1)
laLen(1,1) = 1
SELECT;
MAX(LEN(GETWORDNUM(TRIM(vNR),lnloop1+1,'.')));
FROM curHelp INTO ARRAY laLen
REPLACE ALL;
vHelp WITH GETWORDNUM(TRIM(vNR),lnloop1+1,'.'),;
vSort WITH vSort+;
ICASE(EMPTY(vHelp),'',;
ISDIGIT(vHelp),PADL(vHelp,laLen(1,1),'0'),;
PADR(vHelp,laLen(1,1)))
ENDFOR
but I dislike it a bit.
Agnes
>I suggest that you select into a cursor, something like this semicode
>Select *,;
> somefunc1(yourfield) as sort1,;
> somefunc2(yourfield) as sort2,;
> somefunc3(yourfield) as sort3,;
> somefunc4(yourfield) as sort4;
> from yourtable into cursor yourcursor order by sort1,sort2,sort3,sort4
>Your job will then be to work out the four somefunc() functions, but a combination of val(), getwordnum() and substr() should do the trick. But by doing it this way, you will be able to really see what's happening.
>
>
>>>Still not clear I'm afraid. Taking '1.10.R.1' as an example: As I understand it you break it down to 4 fields (stop is always a seperator - never a decimal point) i.e:
>>>1
>>>10
>>>R
>>>1
>>>For sorting purposes should the items that look like numbers be treated as numbers or character strings? Is there a maximum length to any field within a record or for the number of fields that a record can contain?
>>>eg. Could '123.345678.ABC.234' occur?
>>
>>Hi Viv, Tore,
>>
>>>Still not clear I'm afraid.
>>You are not the only one.
>>
>>I try to answer all at once here.
>>
>>The point separates the words. (It would be
Decimal separator anyway because this is germany 1k=1.000; a tenth = 0,1)
>>
>>The lenght of a single word is limited by the length of the field that holds the value.
>>
>>The words are numbers only in the sense of sort. I think words starting with an alpha should go behind those starting with numbers.
>>
>>*sorted
>>1.01
>>1.2
>>1.10.R.1
>>1.200
>>1.R
>>
>>the field is 40 chars, so worst case could be a single word of 40 chars or 21 words of a single char.
>>
>>Did I mention that I found a record with 10DP, eg mixed digits/alphas in a word? I hate this. I have no idea where to sort this in. This is out of the specs but what does the customer care about specs?
>>
>>
>>Agnes
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord
Weeks of programming can save you hours of planning.
OffThere is no place like [::1]