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:00:32
 
 
To
14/11/2006 07:52:32
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01169359
Message ID:
01169426
Views:
8
Tore -- from an earlier response of mine:

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.



>Can you give me some examples of data which it will not work for?
>
>>Tore -- it almost always does, but not always, so this won't quite work. Thanks anyway
>>
>>>If the text part always comes first:
>>>Lparameters lcInData
>>>Local lnX
>>>#define cStop '()1234567890'
>>>For lnX=1 to Len(Trim(lcInData))
>>>  If Substr(lcInData,lnX,1)$cStop
>>>    lnX = lnX - 1
>>>    Exit
>>>  EndIf
>>>EndFor
>>>Return Substr(lcInData,1,lnX)
>>>
>>>
>>>>I have an odd problem which is not quite handled by STRTRAN, and I'm looking for suggested approaches to the problem. (Tain't a big problem, but sometimes it helps to see how others think of things).
>>>>
>>>>My problem is that my customer has a field (in their database, not one I have any control over), in which they combined two fields -- part description and UPC code. They also have another field for the UPC Code (12 numeric). I need to extract just the part description, deleting the UPC Code.
>>>>
>>>>The difficulty arises because the UPC Code in this combined field frequently has embedded spaces (UPC Code might be "112345123451", and the combined field might read "Small Widget (1 12345 12345 1)"). As usually happens, most of these are entered the same way, but not all -- and there are quite a variety of ways used to embed the extra spaces.
>>>>
>>>>So, how do I go about doing this STRTRAN-equivalent? (I note that I can tell IF the UPC Code is in the combined field by removing all spaces from the combined field and then using $ ... but this doesn't tell me how to make the replacement. I also should note that sometimes there are multiple consecutive embedded spaces.)
Jim Nelson
Newbury Park, CA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform