Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reading variables from a character delimited field.
Message
De
15/03/2001 13:37:49
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00484959
Message ID:
00485493
Vues:
11
Bryan
Try this

lcData='Steve;Dave;John;Fred' && read field data
lnItems=occurs(';',lcData) && get number of elements
Dime newarray(lnItems) && ther may be one more afer the last ';'

for q=1 to lnItems
newarray(q)=left(lcData,at(';',lcData)-1)
lcData=subs(lcData,at(';',lcData)+1)
endfor
if !empty(lcData) && if there is one more
Dime newarray(lnItems+1) && ie last item with no ';'
newarray(lnItems+1)=lcData
endif

If the last item will always NOT be terminated by ';'

lcData='Steve;Dave;John;Fred' && read field data

Dime newarray(occurs(';',lcData)+1)
for q=1 to occurs(';',lcData)
newarray(q)=left(lcData,at(';',lcData)-1)
lcData=subs(lcData,at(';',lcData)+1)
endfor
newarray(occurs(';',lcData))=lcData

I don't think I can get this into any less code
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform