Find/Replace woes

Jim Ault JimAultWins at yahoo.com
Thu Nov 16 13:48:30 CST 2006


On 11/16/06 9:22 AM, "Adrian Williams" <adrian at clubtype.co.uk> wrote:

> hello list,
> I have one field "edtText" that contains text to be found/replaced.
> One field for User to enter text to be found along with a button.
> One field for User to enter text the replace text along with a button.
> All are on the same card.
> The logic and syntax look correct to me, but nothing gets replaced in
> the edtText field.
> It does not generate an error. Anyone have any ideas?
> 
> SCRIPT: FIND BUTTON
> on mouseUp
>    set text of field "edtReplace" to ""
>    put text of field "edtFind" into tFindText
>    find string tFindText in field "edtText"
> end mouseUp
> 
> SCRIPT: REPLACE BUTTON
> on mouseUp
>    get the htmlText of field "edtText"
>    replace text of field "edtFind" with text of field "edtReplace" in it
>    set the htmlText of field "edtText" to it
> end mouseUp

Works here (Rev 2.7.2, Mac OSX 10.4.8) for PLAIN text in the edtText field.


[1] Is there a reason for using 'htmlText of fld edtText '?
As you can see in my example, the htmlText includes tags that become part of
the replacement, 
thus "blue cow" shows in the field,
but " blue</font> cow" is in the actual string

<p>brown fox</p>
<p>lazy dog</p>
<p> <font color="#0000FF">blue</font> cow</p>

In addition, the user may not know that he could also be damaging hidden
tags that will change the display of the text.

[2]You might try opening Tools:Application Browser to look for an extra
field that might be interfering.

You may also note that using the 'replace' will apply this change to any/all
occurrences of the string.

 Jim Ault
Las Vegas





More information about the use-livecode mailing list