Naming Custom Properties

Peter Brigham MD pmbrig at gmail.com
Fri Apr 16 20:39:20 CDT 2010


On Apr 16, 2010, at 2:06 PM, DunbarX at aol.com wrote:

> I have no issue with this. I remember a while back that single char
> properties or variables caused a problem. I tested this in a button:
>
> on mouseenter
>    put random(99) into xxx
>    set the xxx of me to xxx
>    put the xxx of me
> end mouseenter
>
> gives a bunch of random number whenever you enter the object.
>
> Craig Newman
____________

Interesting -- I decided to try to get to the bottom of this. I  
probably haven't gotten to the bottom, but I found out some stuff. If  
I put the following in the script of button "set":

on mouseUp
    put empty into msg
    put "contents 1" into z
    set the yyy of this card to z
    set the w of this card to z
    put "prop contents are" && quote & z & quote \
           into tResult
    put cr & "the yyy of this card =" && (the yyy of this card) \
           & cr & "the z of this card =" && (the z of this card) \
           & cr after tResult
    put tResult
end mouseup

when I click then I get:

prop contents are "contents 1"
the yyy of this card = contents 1
the w of this card = contents 1

Put the following into the script of button "get":

on mouseUp
    put the yyy of this card into yyy
    put the w of this card into zzz
    put the w of this card into z
    put "yyy =" && yyy & cr after tResult
    put "z =" && z & cr after tResult
    put "zzz =" && zzz after tResult
    put tResult after msg
end mouseup

and you get:

yyy = contents 1
z = contents 1
zzz = contents 1

So you *can* usually use single-char prop names to store and retrieve  
customprops,
BUT
If you change the top handler to

on mouseup
    put empty into msg
    put "contents 1" into w
    set the yyy of this card to w
    set the w of this card to w
    --   *****    prop name is same as variable name
     put "prop contents are" && quote & z & quote \
           into tResult
    put cr & "the yyy of this card =" && (the yyy of this card) \
           & cr & "the w of this card =" && (the w of this card) \
           & cr after tResult
    put tResult
end mouseup
...
and then try to retrieve the property with the "get" button:
    put the yyy of this card into yyy
    put the w of this card into zzz
    put the w of this card into z

you get:

yyy = contents 1
z =
zzz =

So if you set a customprop w to w, it appears empty if you then try to  
get the prop and put it into a variable. The strange thing is that the  
engine can interpret "the w of this card" correctly in
put ... "the w of this card =" && (the w of this card)... after tResult
in the same handler it was set in. It just can't put "the w of this  
card" all by itself into a variable in a separate script. There seems  
to be a very specific glitch here.

Is there a bug report on this? I was unable to find one. It is rather  
obscure bug but it points to some wrinkle in the engine that should  
probably be looked at.

A stack for exhibiting this behavior is at
http://home.comcast.net/~pmbrig/custPropTest.rev.zip

-- Peter

Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig




More information about the use-livecode mailing list