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