Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Nice order to create
Message
From
18/03/2016 09:26:03
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
 
To
18/03/2016 07:56:46
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 8.1
Network:
SAMBA Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01633318
Message ID:
01633348
Views:
73
thats the result I've come up with

Thanks for your input
TEXT TO lcx NOSHOW
CDX
1
10
2
03
1.1
12.R
1.1.R
1201.1.RBX.250.R.1
1201.1.R.250.R.1
1201.1.RBX.1.R.1
1.R
1.R.1
A
B
AA
5.R
CDXB
CDX.R
ENDTEXT &&lcx

STRTOFILE(lcx,'xyz.tmp')

CREATE CURSOR curXYZ (cField c(40),cTag c(40))
APPEND BLANK &&just to add an empty record
APPEND FROM xyz.tmp DELIMITED WITH TAB

DELETE FILE xyz.tmp

*get max section length
lnLen = 1
SELECT;
 MAX(GetSectLen(Cur1.cField,@lnLen)) AS nLen;
 FROM curXYZ AS Cur1;
 INTO CURSOR curLen
USE
lnLen = lnLen+2 

SELECT curXYZ
REPLACE ALL cTag WITH IP_ASCII(cField,lnLen)

*create index
TEXT TO lcx NOSHOW TEXTMERGE  
INDEX ON IP_ASCII(cField,<<lnLen>>) TAG anIndex 
ENDTEXT &&lcx 
EXECSCRIPT(lcx)

*there we are
BROWSE LAST NOWAIT

FUNCTION IP_ASCII
 LPARAMETERS;
  tcField,;
  tnLength

 LOCAL;
  lcReturn,;
  lcSection,;
  lnSections,;
  lnSection

 LOCAL ARRAY;
  laCols[1]

 lnSections = ALINES(laCols, UPPER(m.tcField),5,".")
 lcReturn   = ""
 FOR lnSection = 1 TO m.lnSections
  lcSection = laCols(m.lnSection)
  lcReturn  = m.lcReturn + IIF(ISDIGIT(m.lcSection),PADL(ALLTRIM(m.lcSection),m.tnLength,'0'),PADL(ALLTRIM(m.lcSection),m.tnLength,'@'))
 NEXT

 RETURN PADR(m.lcReturn,MIN(LEN(m.tcField),240))
ENDFUNC &&IP_ASCII

*determine max section length in SELECT SQL
FUNCTION GetSectLen
 LPARAMETERS;
  tcField,;
  tnReturn

 LOCAL;
  lnSections,;
  lnSection

 LOCAL ARRAY;
  laCols[1]

 lnSections = ALINES(laCols, UPPER(m.tcField),5,".")
 FOR lnSection = 1 TO m.lnSections
  tnReturn = MAX(m.tnReturn,LEN(laCols(m.lnSection)))
 ENDFOR &&lnSection

 RETURN tnReturn
ENDFUNC &&GetSectLen
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.

Off

There is no place like [::1]
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform