Find/Replace woes

Eric Chatonet eric.chatonet at
Sat Nov 18 04:28:21 EST 2006

Hi Adrian,

May be you could use replaceText:

on mouseUp
   local tFindStr,tRepStr,tText,tHtml,tCanReplace
   put fld "edtFind" into tFindStr
   put fld "edtReplace" into tRepStr
   put fld "edtText" into tText
   put the htmlText of fld "edtText" into tHtml
   put CanReplace(tFindStr,tRepStr,tText) into tCanReplace --
   if tCanReplace then
     set the htmlText of fld "edtText" to replaceText 
   else answer tCanReplace
end mouseUp
function CanReplace tFindStr,tRepStr,tText
   if tFindStr = empty then return "Find string is empty."
   if tRepStr = empty then return "Replace string is empty."
   if tText = empty then return "Text is empty."
   if tFindStr is not in tText then return "Could not find find string."
   return true
end CanReplace

Best Regards from Paris,
Eric Chatonet

Le 18 nov. 06 à 09:46, Adrian Williams a écrit :

> Herschel,
> This works fine if the only word in the "edtText" field matches the  
> "edtReplace" field.
> But if there are ANY other words at all in "edtText", nothing gets  
> replaced.
> So how can Replace be made to actually replace all instances?
> Should this be Replace Text rather than Replace field?
> Thanks,
> Adrian
> On 16 Nov 2006, at 21:24, Hershel Fisch wrote:
>> On 11/16/06 12:22 PM, "Adrian Williams" <adrian at>  
>> wrote:
>>> on mouseUp
>>>  --set text of field "edtReplace" to ""
>> Put "" into fld "edtReplace"
>>>  --put text of field "edtFind" into tFindText
>>> -- find string tFindText in field "edtText"
>> Find fld "edtFind" in fld "edtText"
>>> end mouseUp
>>> on mouseUp
>>>  --get the htmlText of field "edtText"
>>>  --replace text of field "edtFind" with text of field  
>>> "edtReplace" in it
>> Replace fld "edtFind" with fld "edtReplace" in fld edtText"
>>>  --set the htmlText of field "edtText" to it
>>> end mouseUp
>> Whell this is my version ? Hershel
>>> Thanks,
>>> Adrian
>>> ______________________
>>> Club Type
>>> adrian at

----------------------    eric.chatonet at

More information about the Use-livecode mailing list