On 12/16/09 8:04 PM, Kay C Lan wrote:
On Thu, Dec 17, 2009 at 2:49 AM, Robert Brenstein<[email protected]>  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.

Robert

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.

You're right. Variables don't have an "htmlText" property, only fields do. This agrees with the Rev docs description and is the way it really works.

I think maybe Robert meant "variable DON'T have htmltext property", and was saying you can put the htmlText of a field into a variable, manipulate it, then set the htmlText of the field to the manipulated contents of the variable to display it in rendered form.

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:

<p><font color="#FF0000"><b>boink</b></font></p>

If I were to use the keyword 'word', Rev considers

<p><font

to be the first word and the second word is

color="#FF0000"><b>boink</b></font></p>

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.

HTH

I'll take simple over snazzy any day of the week. That way, when I come back to it in six months I might be able to look at the code and immediately know what it's doing! I love it when that happens.

Another approach I've taken is to reformat the htmlText into something more given to processing, then process it, then restore the original format. Like this:

on mouseUp
   get withBoxTags(the htmlText of fld 1)
   put it -- so you can inspect the htmltext output
   set the htmlText of fld 1 to it
end mouseUp


function withBoxTags pHtmlText
   -- replace existing CRs with a char not found in pHtmlText
   replace cr with numToChar(250) in pHtmlText

   -- reformat the text for processing
   replace ">" with (">" & cr) in pHtmlText -- each ">" now ends a line
   replace "<" with (cr & "<") in pHtmlText -- each "<" now starts a line
   filter pHtmlText without empty -- remove blank lines

   -- insert "box" tags
   repeat for each line tLine in pHtmlText
      if char 1 of tLine = "<" -- not a 'data' line
      then put tLine & cr after tNewText
      else put "<box>" & tLine & "</box>" & cr after tNewText
   end repeat

   -- restore original format
   replace cr with empty in tNewText
   replace numToChar(250) with cr in tNewText

   -- return it to caller
   return tNewText
end withBoxTags



The above code may not accomplish exactly what you're trying to do, but it illustrates the idea.
--
Phil Davis

PDS Labs
Professional Software Development
http://pdslabs.net

_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to