Page 1 of 1
Get text from radio button
Posted: Fri Mar 06, 2015 3:35 pm
by gepponline
Hi!
how should i do to get the text of the selcted button of a radio button group?
I'm here:
Code: Select all
get the hilitedbutton of group MYRadioButtons
put it into tSelected
now i'd like to do domething like:
Code: Select all
put the text of item tSelected of group "MYRadioButtons" into FINALVARIABLE
obviously the last string of code is wrong...what should i use to do that?
thank you!
Re: Get text from radio button
Posted: Fri Mar 06, 2015 3:46 pm
by dunbarx
Hi.
Buttons are containers, sort of like fields. They just do not display their data in readable form like a field. So you almost had it:
Code: Select all
put button "yourButton" into field "yourField"
Now you have to already have text in that button, and you do that the same way:
Code: Select all
put yourText into button "yourButton"
As for getting this from a group of radio buttons, you had that as well:
Code: Select all
on mouseUp
answer the text of btn the hilitedButton of group "yourRadioButtonGroup"
end mouseUp
Craig Newman
EDIT:
I assume you really meant the text of a button, and not its name or label. True?
Re: Get text from radio button
Posted: Fri Mar 06, 2015 3:48 pm
by gepponline
Thank you.
Maybe i've found what i was looking for in another topic.
I should use hilitedbuttonname instead of hilitedbutton.

Re: Get text from radio button
Posted: Fri Mar 06, 2015 4:38 pm
by Klaus
Yes!
Or use this cumbersome way:
Code: Select all
...
## No need to use IT and ALWAYS put names in quotes!
put the hilitedbutton of group "MYRadioButtons" into tSelected
put the short name of btn tSelected of grp "MYRadioButtons" into FINALVARIABLE
...

Re: Get text from radio button
Posted: Fri Mar 06, 2015 7:08 pm
by jacque
Note there's a difference between the text of a button and it's name. Sounds like you wanted the name. The text would give you its contents, like for example the list of menu items a pulldown button holds.
Edit : I see Craig already mentioned this. Oops.
Re: Get text from radio button
Posted: Fri Mar 06, 2015 9:51 pm
by SparkOut
Just to restate though, a radio button can also (probably will) have a label, which is the visible er.. label next to the radio button itself (unless you never set a label, in which case it will seem as if the label text displayed next to the button is the name). If someone selects the option against the label "Choice One" then quite possibly retrieving that label is more useful than the button name which might well be named for your own coding conventions rather than the benefit of a user, since in that case, it wouldn't be seen.
Re: Get text from radio button
Posted: Sat Mar 07, 2015 9:23 am
by gepponline
Yes you're right... I'm using unappropriatelt the name of the button but it' my very first app and I'm impatient to see the effect of my code before the correct programming method

but beeing here writing...
There is hilitedbutton and hilitedbuttonname
Is there even hilitedbuttonlabel or hilitedbuttontext or I have to use the 2 lines of code Klaus suggested for those elements of the button?
Re: Get text from radio button
Posted: Sat Mar 07, 2015 12:26 pm
by Klaus
Hi Geppo,
gepponline wrote:Is there even hilitedbuttonlabel or hilitedbuttontext or I have to use the 2 lines of code Klaus suggested for those elements of the button?
no, you will have to use my two lines, or make them one less readable line:
...
put the LABEL of btn (the hilitedbutton of group "MYRadioButtons") of grp "MYRadioButtons" into FINALVARIABLE
...
Best
Klaus