Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Slow string processing.
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00229755
Message ID:
00229911
Views:
29
>Sure, here's the main loop below. The first DO WHILE and DO CASE are to find the key name, then the next DO WHILE and DO CASE are to extract the associated data piece. The end result is we want to find the field name in the table that is the same as key name and store the data piece in that field.
>
>All the nonsense with ~ and / is because they are the delimiters.
>
>I hope thats enough.
>
>Thanks.
>
>Matt
>
>
>**** CODE PIECE FOLLOWS
>
>do while mpos < len(mresult)
>
> keyname=""
> currchar=substr(mresult,mpos,1)
> if currchar="|"
> mpos=mpos+1
> currchar=substr(mresult,mpos,1)
> endif
> lastchar=substr(mresult,mpos-1,1)
> do while (currchar!="~" or (currchar="~" and lastchar="/")) and ;
> (currchar!="|" or (currchar="|" and lastchar="/")) and mpos < len(mresult)
> do case
> case inlist(currchar,"~","|","+") and lastchar="/"
> * Remove the last slash, its just an escape character
> keyname=left(keyname,len(keyname)-1)+currchar
> case inlist(currchar,"~","|","+") and (lastchar!="/" or empty(lastchar))
> * Not an escaped character, so don't add it
> otherwise
> keyname=keyname+currchar
> endcase
> mpos=mpos+1
> lastchar=currchar
> currchar=substr(mresult,mpos,1)
> enddo
>
> keydata=""
> currchar=substr(mresult,mpos,1)
> lastchar=substr(mresult,mpos-1,1)
> do while (currchar!="|" or (currchar="|" and lastchar="/")) and mpos < len(mresult)
> do case
> case inlist(currchar,"~","|","+") and lastchar="/"
> * Remove the last slash, its just an escape character
> keydata=left(keydata,len(keydata)-1)+currchar
> case inlist(currchar,"~","|","+") and (lastchar!="/" or empty(lastchar))
> * Not an escaped character, so don't add it
> otherwise
> keydata=keydata+currchar
> endcase
> mpos=mpos+1
> lastchar=currchar
> currchar=substr(mresult,mpos,1)
> enddo
>
>
> * Get the number off the end of the keyname to tell us what record we're working with
>
> mdigits=""
> numdigits=1
> do while val(right(keyname,numdigits))!=0 or right(keyname,numdigits)==replicate("0",numdigits)
> numdigits=numdigits+1
> enddo
> mdigits=right(keyname,numdigits-1)
> if !empty(mdigits)
> if val(mdigits)>workrec
> * New record needed
> workrec=val(mdigits)
> append blank
> endif
> endif
>
> * Gotta replace the digits with a _ in order to replace the field name
> if numdigits>1
> fieldname=left(keyname,len(keyname)-numdigits+1)+"_"
> else
> fieldname=keyname
> endif
>
> * Now fill the field
> set exact on
> if ascan(fnames,fieldname)>0 and !empty(fieldname)
> replace (fieldname) with keydata
> endif
>
>enddo

Hi Mark,

Without looking at this terribly closely, it appears that you're trying to exact sections of strings that are delimited by |, ~, and /. If that's correct, there are functions in Foxtools that can help. Here's a short snippet that will demonstrate, using these characters
* Get the number of words
lnnumwords = Words(lcresult, "|~/")
* Loop throught the string and display each one
FOR lni = 1 TO lnnumwords
  ? WordNum(lcresult, lni, "|~/")
NEXT
hth,
George

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

Click here to load this message in the networking platform