Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
List elements of a field in an array
Message
 
À
20/04/2004 12:35:06
Steven Dyke
Safran Seats USA
Texas, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00896552
Message ID:
00896605
Vues:
11
>How can I get each element in a field in to an array?
>
>The field schres has data such as SDE,EPY,CMA
>
>My select statement:
>Select schres From schtbld Where schwk = CTOD("04/18/04") And !Empty(schres) InTo Array sch_man_power
>
>yeilds the entire string as first element of array. I need SDE as first element, EPY as second element, and so on.
>
>Thanks for help

Just exercising the alternatives :)
Assuming that there may be multiple records in the result set, any number of codes in the field, but all the codes have three characters:
DIMENSION laValues[1]
lcfields = ""

* calculate the highest number of codes in the field
SELECT MAX(GETWORDCOUNT(schres, ",")) FROM schtbld INTO ARRAY acount1

* build the fields string for SELECT statement
FOR N = 1 TO acount1[1]
	lcfields = lcfields + " PADR(GETWORDNUM(field1," + TRANSFORM(N) + ", ','), 3,' ')" +;
        IIF(N < acount1[1], ',','')
ENDFOR

SELECT &lcfields FROM schtbld WHERE... INTO ARRAY laValues
However, you should deal with possible empty elements.
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform