Rename labelsbuttons

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
JasonTravers
Posts: 7
Joined: Fri Mar 13, 2009 6:23 pm

Rename labelsbuttons

Post by JasonTravers » Fri Sep 25, 2009 8:33 pm

Hi everyone. I am trying to relabel buttons on a card without relabeling each button individually. The find/replace feature doesn't seem to identify the label of a button (or maybe I just don't know how to search! :O)
Is there a line of code I could use in the message box to relabel all of the buttons?
Or am I not finding/replacing properly?

THANKS!
Jason

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

Post by bn » Fri Sep 25, 2009 9:26 pm

Jason,
if I understand you correctly then you want to set the label of all the buttons of a card to the same label?
You can do that by putting this script into the stack script

Code: Select all

on relabelButtons pNewButtonName
   if pNewButtonName is not empty then
      repeat with i = 1 to the number of buttons of this card
         set the label of button i to pNewButtonName
      end repeat
   else
      answer "no new label for the buttons was passed as a parameter" & return & "syntax: relabelButtons " & quote & "myNewLabelName" & quote
   end if
end relabelButtons
You can than invoke this command by typing into the messag box:
relabelButtons "myNewButtonLabel"
If you dont provide a name a dialog appears with the syntax of the command.
The command changes the labels of all the buttons on this one card to "myNewButtonLabel", if you go to the next card you could change the labels of all the buttons of that card and so on.

Of course if you dont want all the buttons to have the same label you would have to check for the label and change it accordingly in the script.
regards
Bernd

Post Reply