Problem Calling Custom Card Props with the Same Name Using Switch
Gregory Lypny
gregory.lypny at videotron.ca
Sun Nov 29 19:57:43 EST 2009
Hello everyone,
Can we assign the same name to custom props of two different objects, for example, the modificationDate of Card 1 and the modificationDate of Card 2?
I created a simple stack with two cards named First Card and Second Card, a common button that assigns custom props to each and another common button to show the values of each card's custom prop. The handler in the button that sets the custom props uses Switch and it looks like this.
on mouseUp
switch the short name of this card
case "First Card"
set the x of this card to 123
set the y of this card to 456
break
case "Second Card"
Set the y of this card to "ABC"
set the z of this card to "DEF"
break
end switch
end mouseUp
What is important here is that both cards have a custom prop with the same name, y, and that y has a different value for each (123 or ABC). The button to show the values of the props also uses Switch.
on mouseUp
put the short name of this card
switch the short name of this card
case "First Card"
put the x of this card into x
put the y of this card into y
put return & "x" && x && "y" && y after msg
break
case "Second Card"
put the y of this card into y
put the z of this card into z
put return & "y" && y && "z" && z after msg
break
end switch
end mouseUp
If you click this button while on the first card, it correctly puts into the message box
First Card
x 123 y 456
But if you click it while on the second card, you get
Second Card
y z DEF
where y is empty. But, comment out the statement involving y in the first case of Switch and the second case will work correctly!
case "First Card"
put the x of this card into x
-- put the y of this card into y
put return & "x" && x && "y" && y
break
In other words, a statement that retrieves a custom prop in the case of Switch that should be by-passed is somehow affecting the retrieval and use of a custom prop with the same name in the case of Switch that is executed. I hope someone can tell me that I've made a mistake because, otherwise, this could have serious consequences for stacks whose objects have custom props that monitor the state of an object and these props have the same names, e.g., the modificationDate of Card 1, the modificationDate of Card 2, etc.
Regards,
Gregory
More information about the use-livecode
mailing list