Problem with setting htmlText of field to empty in LiveCode 6.6 RC2

Trevor DeVore lists at mangomultimedia.com
Wed Mar 19 16:46:18 EDT 2014


On Wed, Mar 19, 2014 at 3:24 PM, Scott Rossi <scott at tactilemedia.com> wrote:

> Using <html> was an example.  If you have <p></p> in an HTML file, the
> browser will still render the HTML as empty. Of course there are tons of
> tags will accomplish the same.
>

Ah, but if you had a style applied to p that shows a border then the border
would be rendered by the browser. So from a DOM point of view you do have a
line.

p {
border: 1px solid red;
}

So if I were to put the htmltext of an empty field into an HTML document I
would end up with an object in the DOM that I wouldn't necessarily expect
to be there.

That being said, I don't think the hmltext property is designed to behave
like I am interpreting it and I think I've changed my mind. I just looked
at the styledText and it also returns an array with 1 line, even if there
is no text:

1
     runs:

So, like Mark said, you can identify the type of formatting that a variable
contains based on these indicators. <p></p> for htmlText, an array for
styledText, etc. So while I agree that it isn't intuitive at first (I was
stumped by this when I first started working with htmltext/styledText and
empty content) it probably is the appropriate behavior.

Now, looking at Jacque's example, I wonder if the language could help us
here (at least in the future). Her example involved storing the htmltext of
a field somewhere and then checking the value later on to see if it is
empty. What if you could check a text length property of a variable to get
the number of characters?

if the text length of the cMyHTMLTextValue of me is 0 then ...

This could, of course, be scripted right now on your own. But it might be a
nice way of checking the string length of any variable that holds text in
any format. Just an idea. It may be better to just leave it up to the
developer to know the format they are storing the text data in and do the
appropriate checks.

-- 
Trevor DeVore
Blue Mango Learning Systems
www.screensteps.com    -    www.clarify-it.com



More information about the use-livecode mailing list