Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Odd string replacement: STRTRAN but with embedded spaces
Message
From
14/11/2006 08:32:38
 
 
To
14/11/2006 01:50:13
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., New Zealand
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01169359
Message ID:
01169434
Views:
8
John --

This certainly appears to be a working solution alright.

Just out of curiousity, is your use of lnChar = 10000 necessary? I can see why you'd probably include that when trying it out, but I don't see how there can be a case where it would be necessary; it seems that once you've found the match with all blanks removed, then the remaining code would always work properly.

>James,
>
>OK. I suppose you want the brackets removed as well if they exist around the UPC. ;-) Plus the UPC removed with white space wherever it occurs?
>
>OK.
>
>
>lnCounter=1
>lcUPC=alltrim(cUPC)
>lcInit=left(m.lcUPC,1)
>lcPart=cPart
>
>lnAt=at(m.lcInit,m.lcPart,m.lnCounter)
>
>do while m.lnAt>0
>  if chrtran(substr(m.lcPart,m.lnAt),[ ],[])=m.lcUPC
>    lcPart1=rtrim(left(m.lcPart,m.lnAt-1))
>    lcPart2=ltrim(substr(m.lcPart,m.lnAt))
>
>    for lnChar=1 to len(m.lcUPC)
>      if m.lcPart2=substr(m.lcUPC,m.lnChar,1)
>        lcPart2=ltrim(substr(m.lcPart2,2))
>        *---done this way to eliminate spaces...
>      else
>        lnChar=1000000
>      endif
>    endfor
>
>    if m.lnChar<=1000000
>      lcPart=strtran(rtrim(m.lcPart1+[ ]+m.lcPart2),[( )],[])
>      exit
>    endif
>  endif
>
>  lnCounter=m.lnCounter+1
>  lnAt=at(m.lcInit,m.lcPart,m.lnCounter)
>
>enddo
Jim Nelson
Newbury Park, CA
Previous
Reply
Map
View

Click here to load this message in the networking platform