Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
STRTRAN not matter the case sensitive
Message
From
29/09/1997 21:56:25
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00051652
Message ID:
00052335
Views:
37
>>I have a situation where I am using STRTRAN to replace some text in a
>>memo
>>field. It goes like this:
>>
>>REPLACE mymemo WITH STRTRAN(mymemo,'my text','new text')
>>
>>But, sometimes, in the memo field, the text that need to replaced is
>>either
>>lower case, upper case or a mix of both.
>>
>>If I use something like this:
>>
>>REPLACE mymemo WITH STRTRAN(UPPER(mymemo),'MY TEXT','new text')
>>
>>it will replace all the variations of my text but will also replace
>>the
>>memo field in uppercase. How, can I get all the variations by keeping
>>the
>>memo field as is?
>
>Disclaimer: This is untested, and there is no error checking.
>
>procedure CaseInsensitiveStrTran
>parameter tcCompleteString, tcStringToReplace, tcNewString
>
>private lnLocation, lcReturnString
>
>* Ensure that the original value isn't changed, even if passing by
>reference
>m.lcReturnString = m.tcCompleteString
>
>* Find the first location of the string
>m.lnLocation = at(upper(m.tcStringToReplace),upper(m.tcCompleteString))
>
>* Since at least one location of the string was found, replace them all
>do while m.lnLocation # 0
> * Remove the old text, insert the new
> m.lcReturnString = ;
>
>stuff(m.lcReturnString,m.lnLocation,len(m.tcStringToReplace),m.tcNewString)
> * Find the next occurence of the string
> m.lnLocation =
>at(upper(m.tcStringToReplace),upper(m.tcCompleteString))
>enddo
>
>* Return the adjusted string
>return m.lcReturnString

Thanks, I'll keep this one in my archive.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Reply
Map
View

Click here to load this message in the networking platform