Kay C Lan
lan.kc.macmail at gmail.com
Wed Dec 16 23:04:59 EST 2009
On Thu, Dec 17, 2009 at 2:49 AM, Robert Brenstein <rjb at robelko.com> wrote:
> A tad safer and more general technique is to
> put "<box>" before word 2 of tHtml
> put "</box>" after word 2 of tHtml
> As other said, variable have htmltext property, just the content which can
> be html, so you need to work with it directly. Html comes into effect when
> such a content is put into a field and then displayed to user.
I'm totally confused. I am not aware that variables have a htmlText
property? When I try to access it I keep getting an error message.
Secondly, using the keyword 'word' when dealing with htmlText doesn't seem
to be a safe option to me at all, in fact it would be the last option I'd
think of using. If a field contained multiple lines of words, formatted in
all sorts of weird and wonderful ways, and the htmlText of one of those
lines might look like this:
If I were to use the keyword 'word', Rev considers
to be the first word and the second word is
putting "<box>" and "</box>" before and after any of these words will result
in ill formed HTML.
Granted, if you do a grep for >([^<]*)< you can extract just the content
between the html tags and then using the 'word' keyword will work for you.
But now that I appreciate that this original post is related to another post
where I put forward the idea of using the 'token' keyword, I'll suggest it
again. Doing grep and trying to keep track of where in a line of html text
you are and what word needs to be replaced with what, plus needing to deal
with all the punctuation marks that get included inside what Rev considers
is a word, is very involved for this old brain and dare I say, unsafe or at
least fraught with possible errors. Using token, there are only a few
special characters you have to account for, you can then just run through
every token and when you get a match:
put "<box>" & token tTokenCounter of tHtmlText & "</box>" into token
tTokenCounter of tHtmlText
Probably not the fastest way, but relatively simple.
More information about the Use-livecode