Page 1 of 1
Finding owner of a button
Posted: Sat Nov 17, 2018 10:46 pm
by kaveh1000
I have two buttons in a group. My script in one of the buttons says:
Code: Select all
on mouseup
if the owner of the target is group "mine" then answer "yes"
end mouseup
But I get the following error when I click:
Code: Select all
button "Button": execution error at line 2 (Chunk: source is not a container), char 1
Any ideas pls?
Re: Finding owner of a button
Posted: Sat Nov 17, 2018 11:15 pm
by SparkOut
If you "put the owner of the target" you will see that it returns the string literal:
group "mine"
When it comes to your comparison, the string literal needs to be quoted. So you would need to check thus:
Code: Select all
if the owner of the target is "group" && quote & "mine" & quote then answer "yes"
You could make this neater by putting "the owner" into a variable and parsing with maybe "contains" or some such, but your problem is the comparison against the "owner of the target" that returns a string literal which contains quotes, so you need to work around that in some way.
Re: Finding owner of a button
Posted: Sun Nov 18, 2018 12:38 am
by kaveh1000
Thank you so much @SparkOut. That gave me the hint, so the following now works:
Code: Select all
on mouseup
put the owner of the target into the_owner
delete char 1 to offset(quote, the_owner) of the_owner
delete char -1 of the_owner
if the short name of the owner of the target is the_owner then
answer "yes"
end if
end mouseup
I tried using replacetext() but I can't escape the quote mark!
Re: Finding owner of a button
Posted: Sun Nov 18, 2018 2:14 pm
by bogs
Escaping the quote marks is this part of the code from above -
As far as I could see, it should work out flawlessly?
Re: Finding owner of a button
Posted: Sun Nov 18, 2018 3:03 pm
by jmburnod
Hi All,
why not use the short name of the owner ?
Code: Select all
if the short name of the owner of the target = "mine" then answer "yes"
works for me
Is there something i dont understand ?
Best regards
Jean-Marc
Re: Finding owner of a button
Posted: Sun Nov 18, 2018 3:10 pm
by kaveh1000
Thanks Jean-Marc. So obvious in hindsight! Thank you. I am not as clever as I thought.

Re: Finding owner of a button
Posted: Sun Nov 18, 2018 4:33 pm
by jmburnod
I am not as clever as I thought
Welcome to the club
