Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Produce a Complex String
Message
 
 
À
10/12/2007 11:38:08
Steven Dyke
Safran Seats USA
Texas, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP1
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01274465
Message ID:
01274466
Vues:
11
>An example of my data:
>
>Part No    Recseq
>854411-401 0000001
>854411-402 0000002
>854411-403 0000003
>854411-405 0000004
>854411-405 0000005
>854411-405 0000006
>854411-407 0000007
>
>My desired string:
>854411-401(000001),854411-402(000002),854411-403(0000003),854411-405(0000004,0000005,0000006),854411-407)
>
>This is the code I have came up with which almost works except it puts an ")" after the first -405 recseq number and no ")" after the last -405 recseq number(any multiple part numbers).
>
>CLEAR
>SET EXACT On
>partnoS = ""
>partnoS2 = ""
>recseqS2 = ""
>openP = ""
>closeP = ""
>
>SELECT testQuery
>SCAN
>		
>	IF AT(ALLTRIM(testQuery.partno), partnoS2) < 1 Then
>		
>		partnoS = ALLTRIM(partno)+"("
>		closeP = "),"
>	ELSE
>		partnoS = ""
>		closeP = ","
>	ENDIF
>	partnoS2 = partnoS2 + ALLTRIM(partno)
>	recseqS2 = recseqS2 + partnoS + recseq + closeP
>ENDSCAN
>
>? recseqS2
The general principle is to hold the current part in the variable. Once you found that your variable is not equal to the current part you may do your closing code and update the variable.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform