Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need idea for sort
Message
From
26/02/2010 09:57:09
Thomas Ganss (Online)
Main Trend
Frankfurt, Germany
 
 
To
26/02/2010 07:51:11
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01451160
Message ID:
01451237
Views:
45
Agnes,

very ugly as you need up to 21 "words", written for 4 words only.... and untested

regards

thomas
dimension paLen[4], paSql[4]

SELECT;
   MAX(LEN(GETWORDNUM(TRIM(Cur2_1.cName),1,'.'))) ;
   , MAX(LEN(GETWORDNUM(TRIM(Cur2_1.cName),2,'.'))) ;
   , MAX(LEN(GETWORDNUM(TRIM(Cur2_1.cName),3,'.'))) ;
   , MAX(LEN(GETWORDNUM(TRIM(Cur2_1.cName),4,'.'))) ;
   FROM curSource AS Cur2_1;
   into Array paLen

Select MyFunc(cName) as v1;
, paSql[2] as v2;
, paSql[3] as v3;
, paSql[4] as v4;
from FROM curSource ;
order by 1,2,3,4

function MyFunc(tcName)
local lnRun, lcWord
for lnRun = 1 to Alen(paLen)
  lcWord = getWordNum(tcName, m.lnRun, ".")
  paSql[m.lnRun] = icase( empty(m.lcWord), Space(2*paLen[m.lnRun]) ;
     , IsDigit(Alltrim(m.lcWord)), Str(Val(m.lcWord), paLen[m.lnRun]) + Padr(StripLeftDigits(Alltrim(m.lcWord)), paLen[m.lnRun]) ;
     , Replicate("x", PaLen[m.lnRun]) +  Padr(m.lcWord, paLen[m.lnRun]) )
next
return paSql[1]

Function StripLeftDigits(tcWord)
local lnRun
*-- as the func should only be called with leading digits
for lnRun = 2 to len(m.tcWord)
  if !isdigit(Substr(m.tcWord, m.lnRUn, 1))
     exit
  endif
next
return Stuff(m.tcWord, 1, m.lnRUn-1, "")
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform