Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Nice order to create
Message
De
18/03/2016 16:34:01
Thomas Ganss (En ligne)
Main Trend
Frankfurt, Allemagne
 
 
À
18/03/2016 16:28:50
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 8.1
Network:
SAMBA Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01633318
Message ID:
01633382
Vues:
46
even worse: you wouldhave to reindex the whole file each time one of the parameters changes. The beauty of setting the UDF as index is that it only recalculates changed fields index for that particular row - so do NOT make the function dependant on a single field! Pre-set numbers give you HUGE advantage here ;-))

>MIN (240,max(count(sections))*tnLength)
>
>but you are right, 240 is good enough and possibly it is faster to have the long index then to calc the len and min over and over
>
>>>>> RETURN PADR(m.lcReturn,MIN(LEN(m.tcField),240))
>>will be wrong if you have tnLength*lnSections larger than LEN(m.tcField)
>>as user can input more dots, your code will misbehave in the long run.
>>Just set it to 240....
>>
>>>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
>>>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform