Changing Button Labels with script - Solved

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Changing Button Labels with script - Solved

Post by DR White » Fri Aug 23, 2013 4:14 pm

How do you change Button Labels with script?


The script below does not work, Why?

set the label of Button1 to "David"

Thanks,

David
Last edited by DR White on Thu Sep 19, 2013 2:57 am, edited 1 time in total.

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Changing Button Labels with script

Post by DR White » Fri Aug 23, 2013 4:32 pm

Sorry to be such a bother!

After looking at some more examples and beating my head against the wall, I saw my error.

The code should have been:

set the label of button Button1 to "David"

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

Re: Changing Button Labels with script

Post by dunbarx » Fri Aug 23, 2013 6:30 pm

Good work.

Do you see that the first script was syntactically correct? But that it changed the label of a button you were not interested in? Did you see that label change, and did that give you a clue as to what you really needed?

Craig Newman

Klaus
Posts: 14222
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Changing Button Labels with script

Post by Klaus » Fri Aug 23, 2013 6:31 pm

Hi David,

check these great stacks to get the "grips" of Livecode :-)
http://www.hyperactivesw.com/revscriptc ... ences.html


Best

Klaus

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7395
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Changing Button Labels with script

Post by jacque » Fri Aug 23, 2013 7:48 pm

I didn't see the error immediately either -- which is why I try not to name objects starting with their type. I.e., I avoid names like "button1" because when I read it I don't notice any problem. If I name it something descriptive like "Next page" then the missing object specifier is easy to spot. It's kind of too bad the IDE does that sort of naming by default. I always change them.

Sometimes I do want the object type in the name though. In those cases I put it at the end: "editingFld" or "firstnameLbl" to avoid trip-ups.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: Changing Button Labels with script

Post by dunbarx » Fri Aug 23, 2013 9:23 pm

Well, now that I read it correctly...

So you got an error. I thought is was "button 1", when in fact it was "button1". You did not have an object identifier, only a name.

You could do something to "button 1" (the first button). But you need to specify what object "button1" is. Could be a field.

Craig

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Changing Button Labels with script

Post by DR White » Sat Aug 24, 2013 2:05 am

Craig,

Thanks for your following of my posts and your understanding :) .

The "Button1" is not a good name in a real program,
I am just writing a test program to explore what LiveCode can do in my current project to develop an mobile app for my Sunday school class.

David

Post Reply