Challenge: how to set the text of a field
David Bovill
david at vaudevillecourt.tv
Fri Mar 29 17:07:44 EDT 2013
OK - lets rename the challenge :) Same problem - but defining it as follows:
- Is it possible to create a handler in the behavior of a shared group
that returns the number of the card the shared group is on?
This is the same problem - it is a problem of finding a reference to the
card a control is on so that you are able to return values of properties of
the group such as a hilite or text that can differ from card to card. As
far as I know there is actually no way at all to do this.
Although I thought parsing the long id works - it does not. So the
following handler does not work.
getprop card_Number
put the long id of the target into targetObject
repeat
if word 1 of targetObject is "card" then
put the number of targetObject into cardNum
return cardNum
end if
delete word 1 to 4 of of targetObject
if targetObject is empty then return empty -- just in case
end repeat
end card_Number
In fact the behavior of references to shared "background" groups is quite
bizarre! Take the following experiment - create a shared background and
place it on 3 cards - add the handler above to the script of the shared
group. It can be the behavior of the group or its script.
Now given you are on the first card - issue the following from the message
box:
put the card_Number of group 1 of card 3 --> answer is 1
put the card_Number of group 1 of card 2 --> answer is 1
put the card_Number of group 1 of card 1 --> answer is 1
Now try removing the group from the first card, and do the same again:
put the card_Number of group 1 of card 3 --> answer is 3 - ie correct!
put the card_Number of group 1 of card 2 --> answer is 2 - ie correct!
put the card_Number of group 1 of card 1 --> well there isn't one so you
get an error
Summary - this is a bug. It also makes it impossible to define some basic
and useful behaviors for shared "bakground" groups.
More information about the use-livecode
mailing list