Page 1 of 1
Changing Button Labels with script - Solved
Posted: Fri Aug 23, 2013 4:14 pm
by DR White
How do you change Button Labels with script?
The script below does not work, Why?
set the label of Button1 to "David"
Thanks,
David
Re: Changing Button Labels with script
Posted: Fri Aug 23, 2013 4:32 pm
by DR White
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"
Re: Changing Button Labels with script
Posted: Fri Aug 23, 2013 6:30 pm
by dunbarx
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
Re: Changing Button Labels with script
Posted: Fri Aug 23, 2013 6:31 pm
by Klaus
Hi David,
check these great stacks to get the "grips" of Livecode
http://www.hyperactivesw.com/revscriptc ... ences.html
Best
Klaus
Re: Changing Button Labels with script
Posted: Fri Aug 23, 2013 7:48 pm
by jacque
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.
Re: Changing Button Labels with script
Posted: Fri Aug 23, 2013 9:23 pm
by dunbarx
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
Re: Changing Button Labels with script
Posted: Sat Aug 24, 2013 2:05 am
by DR White
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