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 00:35:20
 
 
To
13/11/2006 20:58:48
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:
01169388
Views:
9
Unfortunately, there's no absolute positioning involved here that can be counted on. Since this is a free form text field, what occurs is what you might expect: there are a couple of main ways that the UPC is represented, a main exception, and a couple of special cases:

Main ways:
"Big Widget 1 12345 12345 1"
"Big Widget - 1 12345 12345 1"
Occurs a few times:
"Big Widget (1 12345 12345 1)"
Once only:
"Big Widget 1 12345 12345 1 / China"
"Big Widget Green:1 12345 12345 1"

Can't really count on anything, I'm afraid, other than that the UPC Code appears with white space.

(Further note: The spaces within the UPC Codes above are the usual presentation ... but there's also "1 12345 123451" and "112345 123451" and even "11 2345 12345 1")

>James,
>
>Hmm...
>
>OK, if the description is always first, this would work:
>
>
>
>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
>    lcPart=left(m.lcPart,m.lnAt-1)
>    exit
>  else
>    lnCounter=m.lnCounter+1
>    lnAt=at(m.lcInit,m.lcPart,m.lnCounter)
>  endif
>enddo
Jim Nelson
Newbury Park, CA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform