Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Coding Standards
Message
From
08/07/1998 17:34:51
 
 
To
08/07/1998 14:15:17
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00115272
Message ID:
00115487
Views:
20
>George ---
>
>>
>>Assume you wanted to write a binary search routine to search an ordered list, for the sake of readability alone, you'd want to use a DO WHILE...ENDDO.
>>
>>Or you wanted to break a delimited string down into the inidividual elements. Same thing.
>
>So am I missing something::
>
>cString="Hello"
>nLenString=LEN(cString)
>DIM cChars(nLenString)
>FOR i = 1 TO nLenString
> cChars(i)=SUBSTR(cString,i,1)
>ENDFOR

yes , you are - George talked about delimited list as "item1,item2,item3"
but you can still use a for loop
do something like :
LPARAMETER tcString
* tcString is strings like "item1,item2,item3"
LOCAL lcString,lnNumOccurances,lnI,lnPos

lcString=tcString+"," 
lnNumOccurances=LEN(lcString)-LEN(STRTRAN(lcString,","))

FOR lnI=1 to lnNumOccurances
    lnPos=AT(",",lcString,1)
    * you can do whatever instead of printing 
    ? LEFT(LEFT(lcString,lnPos-1)
    lcString=RIGHT(lcString,len(lcString)-lnPos)
ENDFOR
Arnon
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform