A failure to communicate

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10337
Joined: Wed May 06, 2009 2:28 pm

A failure to communicate

Post by dunbarx » Thu Nov 03, 2022 2:52 am

On a card make two buttons. Name one "XYZ". In the script of the other:

Code: Select all

on mouseUp
   copy button "XYZ"
   paste                            --setting red dot here fails
   set the name of it to "ABC"    --setting red dot here works fine
end mouseUp
Works fine. A new button named "ABC" appears over the original "XYZ".

If you set a red dot breakpoint at the "set the name of..." line, you can see that the local variable "it" has assumed the long name of the newly created button. Stepping through the handler proceeds just fine. But if you set a red dot at the "paste" line, upon stepping through, the variable "it" remains empty, and the handler throws an error.

One has to paste before the new control "assumes" its long name and the variable "it" is populated? The control does not really "exist" when it is merely copied? Maybe this sort of makes sense...

Craig

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: A failure to communicate

Post by bn » Thu Nov 03, 2022 9:55 am

Hi Craig,

I tried your code and setting breakpoints at the places you indicate. The breakpoints and the code worked for me in both places although when I put it before "paste" the variable "it" was empty. But stepping through the code did create the button and renamed it.

LC 9.6.9 rc 1, MacOS 12.6.1

Kind regards
Bernd

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10337
Joined: Wed May 06, 2009 2:28 pm

Re: A failure to communicate

Post by dunbarx » Thu Nov 03, 2022 2:21 pm

Bernd.

Did you use red dots or the "breakpoint' command? It is red dots that fail for me. The command always works.

LC 9.6.1. Mac OS 10.15.7

Craig

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: A failure to communicate

Post by bn » Thu Nov 03, 2022 3:32 pm

dunbarx wrote:
Thu Nov 03, 2022 2:21 pm
Did you use red dots or the "breakpoint' command? It is red dots that fail for me. The command always works.
LC 9.6.1. Mac OS 10.15.7
Craig,

I used red dots.

Kind regards
Bernd

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10337
Joined: Wed May 06, 2009 2:28 pm

Re: A failure to communicate

Post by dunbarx » Thu Nov 03, 2022 5:19 pm

Bernd.

Well, now mine works as well. I did restart LC this morning, so maybe that fixed it.

Thanks for taking the time.

Craig

Post Reply