Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
String to Array
Message
 
To
31/01/2001 10:02:16
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00470612
Message ID:
00470620
Views:
33
>I have a string similar to "text1,text2,text3,etc...". I want to be able to break out each item and store to an array (i.e. STORE "text1" to lArray(i)).
>What is the fastest and easiest way to do this?
>
>Thanks in advance for your help,
Russell,

You can of course use OCCURS(",", lcstring) + 1, then AT() to determine the position etc. I'm sure someone will recommend that. I will, however, recommend the following:
* Assumes Foxtools is one the search path
SET LIBRARY TO FOXTOOLS ADDITIVE
lcstring = "text1,text2,text3"
lnwords = Words(lcstring, ",")
DIMENSION myarray[lnwords]
FOR lni = 1 TO lnwords
  myarray[lni] = WordNum(lcstring, lni, ",")
NEXT
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform