radio buttons - Multiple choice question

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
therock777
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10
Joined: Mon Oct 05, 2009 3:31 am

radio buttons - Multiple choice question

Post by therock777 » Mon Oct 05, 2009 3:51 am

Hi All,
I'm completely new to RunRev, so please bear with me. what I'm trying to do is very simple, however I can't get it right.

I'm trying to create a 1 question multiple choice quiz for testing purposes, I'm using radio buttons with 4 possible choices. My question is, how do I refer in the script to the correct answer? here is my script.

on mouseUp
if button "firstone" is selected then
answer "Good"
else
answer "Wrong"
end if

end mouseUp

even when the correct choice is being selected, I still get the wrong answer.

what am I doing wrong?

Please advise, or point me to the right direction on working with radio buttons.

Thanks,

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Mon Oct 05, 2009 6:14 am

If you haven't done so already, group the four radio buttons. Then use the inspector palette to turn on the radigroupBehavior property of that group.
Now the engine will automatically handle the hiliting-only-one-option part. Next, lookup the following temrs in the rev dictionary: hilitedButton, hilitedButtonId, hilitedButtonName.

HTH,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

therock777
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10
Joined: Mon Oct 05, 2009 3:31 am

Post by therock777 » Mon Oct 05, 2009 8:14 pm

Hi Janschenkel,
Thanks for your reply, based on the outcome I got by following your instructions, it looks like this option allows you to set the default value for a radio button. However, what I'm trying to achieve here is, to have the program to make the correct decision based on the user response.

for example:
if button "Radio1" of group "RadioGroup" is selected then
answer "Correct!"
else
answer "Wrong"
end if

Is this correct?
I apologize for my lack of knowledge, I'm coming from the python programing language, and the environment is totally different.

Thanks,

Paul D
Posts: 116
Joined: Mon May 21, 2007 6:58 pm

Post by Paul D » Mon Oct 05, 2009 9:17 pm

I use the hilitedbuttonname syntax but you can use hilitedbutton for the number of the button if needed.

Edit the script of the group that your buttons are in.

Code: Select all

on mouseup
if the hilitedbuttonname of group "radiogroup" <> "thecorrectanswer" then
answer "Wrong"
else
answer "Right"
end if
end mouseup

Code: Select all

on mouseup
if the hilitedbutton of group "radiogroup" <> 1 then
answer "Wrong"
else
answer "Right"
end if
end mouseup
change the button number to the number of the correct button. you find the button number under size & position in the property inspector... this what you mean?

therock777
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10
Joined: Mon Oct 05, 2009 3:31 am

Post by therock777 » Tue Oct 06, 2009 12:50 am

Thanks Paul D,

This is exactly what I needed, it works now!

Do you know of any Run Rev books, in addition to the user manual? I have been reading the manual, but I need something more informative and concise.

Thanks Again!

Paul D
Posts: 116
Joined: Mon May 21, 2007 6:58 pm

Post by Paul D » Tue Oct 06, 2009 1:29 pm

the only book ive read is Software at the Speed of Thought by Dan Shafer. Its maybe a bit outdated but goes over the basics. You can actually download the examples in the book from runrev...

http://www.runrev.com/downloads/all-dow ... -examples/

therock777
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10
Joined: Mon Oct 05, 2009 3:31 am

Post by therock777 » Tue Oct 06, 2009 5:22 pm

I'll look into it, Thanks.

Post Reply