ok so im working on making a program to use for studying, and i want to use 4 radio buttons for the answers. the answers will come from answer.text. the questions will come from questions.text.
so each line of text will correspond with the other. like line 1 of question.text file corresponds with line 1 of answer.text file.so easy to match up questions with answers.
now how can i make 1 of the radio buttons randomly be the correct answer and not the same button everytime.how can i get the other 3 incorrect to be random lines from the answer.text file and make sure they they are not the same as the correct answer.
more of flow chart question then actually coding question sorry
random radio buttons
Moderators: Dorian (MJT support), JRL
random radio buttons
if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!
No guarantees. I think this is what you want. I wish I could explain it to you but I wrote it last night and how it works is already fuzzy.
Code: Select all
/*
Questions:
What color is an apple?
What color is an orange?
What color is a lemon?
What color is a plum assuming the plum has four minor external blemishes but is still delectable?
*/
//Two sets of answers only for the fun of it.
/*
AnswersBasic:
Red
Orange
Yellow
Purple
*/
/*
AnswersExtras:
Red
Orange
Yellow
Purple
White
Cyan
Copper
Beige
Blue
Green
Black
Brown
Grey
Calculator
Marble
Jet Fuel
*/
LabelToVar>Questions,Qdata
LabelToVar>AnswersExtras,Adata
//LabelToVar>AnswersBasic,Adata
//you will probably need to read your lists into the script.
//ReadFile>Qfile,Qdata
//REadFile>Afile,Adata
Dialog>Dialog1
object Dialog1: TForm
AutoSize = True
Left = 386
Top = 201
Caption = 'Popup Quiz'
ClientHeight = 269
ClientWidth = 345
object Label1: TLabel
Left = 32
Top = 8
Width = 45
Height = 13
Caption = 'Question:'
end
object Label2: TLabel
Left = 32
Top = 32
Width = 58
Height = 13
Caption = 'What color?'
end
object MSRadioGroup1: tMSRadioGroup
Left = 24
Top = 85
Width = 297
Height = 132
Caption = 'Answer: Pick One'
Items.Strings = (
'1'
'2'
'3'
'4')
TabOrder = 0
Text = '1'#13#10'2'#13#10'3'#13#10'4'#13#10
end
object MSButton1: tMSButton
Left = 26
Top = 233
Width = 75
Height = 25
Caption = 'Ok'
Default = True
end
end
EndDialog>Dialog1
Let>ques_count=0
GoSub>PostAQuestion
AddDialogHandler>Dialog1,msButton1,OnClick,PostAQuestion
SetDialogObjectFont>Dialog1,Label2,Arial,14,0,11111
Show>Dialog1,res
SRT>PostAQuestion
Add>ques_count,1
If>Ques_count<>1
GetDialogProperty>Dialog1,MSRadioGroup1,ItemIndex,response
Add>Response,1
If>Response=Apos
MDL>Correct
Else
MDL>Incorrect...%CRLF%Try Again.
Sub>ques_count,1
Goto>RetrySameQuestion
EndIf
EndIf
If>Ques_count=5
MDL> that's all
Exit>0
EndIf
SetDialogProperty>Dialog1,MSRadioGroup1,ItemIndex,-1
Separate>Qdata,%CRLF%,Question
Separate>Adata,%CRLF%,Answer
Let>Ans_list=
//Depending how your list is structured, you my not need the "-1"s
//in the next two lines.
Let>ans_qty=%answer_count%-1
Let>ques_qty=%question_count%-1
Random>ques_qty,Apos
Add>Apos,1
Let>kk=0
Repeat>kk
add>kk,1
If>kk=Apos
Let>value=Answer_%ques_count%
Else
Label>TryAgain
Random>ans_qty,Bad_Ans
Add>Bad_Ans,1
If>Bad_Ans=Ques_Count
Goto>TryAgain
EndIf
Let>value=Answer_%Bad_Ans%
Separate>Ans_list,value,res
If>res_count>1
Goto>TryAgain
EndIf
EndIf
Separate>Adata,%CRLF%,Answer
Concat>Ans_list,%value%%CRLF%
Until>kk=ques_qty
SetDialogProperty>Dialog1,MSRadioGroup1,Text,Ans_list
Let>value=Question_%ques_count%
SetDialogProperty>Dialog1,Label2,Caption,value
ResizeWindow>Popup Quiz,0,0
SetDialogProperty>Dialog1,,Position,poScreenCenter
Label>RetrySameQuestion
END>PostAQuestion
any
LOL! I thought that only happened to me! I completely understand THAT!I wish I could explain it to you but I wrote it last night and how it works is already fuzzy.
Some times reviewing my code makes my head spin and me to ask, "Was I on something?" But yet it works.
Sorry if this is abuse of the forum. But that was just funny.
Windows 7
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!