Bad text...

David Bovill david at vaudevillecourt.tv
Sun Jan 9 03:51:15 CST 2011


On 9 January 2011 01:08, Mark Wieder <mwieder at ahsoftware.net> wrote:

>
> >> getprop bad_Text
> >>    return the text of the target
> >> end bad_Text
> >>
> >> getprop good_Text
> >>    put the long id of the target into targetObject
> >>    return the text of targetObject
> >> end good_Text
> >>
>
> I get the same results with either here. What are you seeing?
>

It's actually pretty annoying - or interesting depending what mood you are
in :)


Very basic:

   - Create a stack with 2 cards
   - Create a field on the second card with the text "Hello World!"
   - Set the stack script to:

getprop bad_Text
>    return the text of the target
> end bad_Text
>
> getprop good_Text
>    put the long id of the target into targetObject
>    return the text of targetObject
> end good_Text


On the first card try "put the good_Text of fld 1 of cd 2", which works as
expected, but  "put the bad_Text of fld 1 of cd 2" returns empty! It gets
even more complicated if you try to get "the properties of fld 1 of cd 2" -
where the "long id" trick no longer works.

This is a basic feature of the way "the target" works and not to do with
using getprop / setprops. I'd call it a serious bug - as this is not how
"the target" should work, even worse is that the simple line "get the
properties of fld 2 of cd 1" returns the wrong result whichever way you
construct it - the only way to get the real properties is a hack like the
following:

put the properties of fld 1 of cd 2 into propArray
put the htmltext of fld 1 of cd 2 into propArray ["htmlText"]

Though in real world scripts you need to check the target is a field, and
add a similar hack for the "hilite"


More information about the use-livecode mailing list