* 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>
>*!****************************************************************************** >function aparser1 >* Description.......: Function parses a text string into an array. >* : Each element of the array contains one word... >* Calling Samples...: dimension laWords[1] >* : lcWordString = "Some text string" >* : lnWords = aparser1(@laWords, lcWordString) >* Parameter List....: taWords, tcWordString, tcDelimiter >******************************************************************** >lparameter taWords, tcWordString, tcDelimiter >local lnWords, lni >external array taWords > >if vartype(tcDelimiter)'C' > tcDelimiter=space(1) && Default delimiter >endif >*!* Replace the delimiter with CHR(13) using STRTRAN. >tcWordString = strtran(tcWordString, tcDelimiter, chr(13)) >*!* Now put each element in an array. >lnWords=alines(taWords, tcWordString) >return lnWords >