[Hilfe von Nöten] Quiz Script

06/08/2010 16:46 SuperZim#1
Hi Leute.

Ich möchte ein Script erstellen, wo einfach ein Fenster mit einer Überschrift (der Frage) und 4 Radiobuttons (die Antworten) erscheint.

Klingt sehr einfach, dennoch krieg ichs nich hin(obwohl ich mit AutoIT Bots scripte, derbst peinlich).

Hinzu kommt das ich nichtmal den Fehler finde.
Zusätzlich ist zu beachten, dass ich mit dem #include Befehl eine Datei "includen" will, die die Fragen enthält. Die Variablen für Frage / Antworten werden dort definiert.

Hauptproblem:
Wie gesagt, das mit den Radiobuttons will nicht so wirklich hinhaun.

Script (Quiz, Hauptscript):

PHP Code:
Script Start Add your code below here


#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <fragen.au3>
$counter=0
While $counter <> 50

#Region ### START Koda GUI section ### Form=
$Form1 GUICreate("Frage"703170193125)
$fragegui GUICtrlCreateLabel($frage[$counter], 248)
GUICtrlSetFont(-1164000"MS Sans Serif")
$antwort1 GUICtrlCreateRadio($mantwort1[$counter], 2472)
GUICtrlSetFont(-1124000"MS Sans Serif")
$antwort2 GUICtrlCreateRadio($mantwort2[$counter], 2496)
GUICtrlSetFont(-1124000"MS Sans Serif")
$antwort3 GUICtrlCreateRadio($mantwort3[$counter], 24120)
GUICtrlSetFont(-1124000"MS Sans Serif")
$antwort4 GUICtrlCreateRadio($mantwort4[$counter], 24144)
GUICtrlSetFont(-1124000"MS Sans Serif")
$Button1 GUICtrlCreateButton("Absenden"5848113153)
GUICtrlSetFont(-1174000"MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$msg
=GuiGetMsg()
Switch 
$msg
Case $msg == $Button1
    
If GuictrlRead($antwort1) == $GUI_CHECKED Then
        
If $a == "richtig" Then
            MsgBox
(0"Richtig!""Das war richtig, Glückwunsch!")
            
ExitLoop
        
ElseIf $a == "falsch" Then
            MsgBox
(0"Falsch!""Das war leider falsch")
            Exit
        EndIf
    EndIf
        If 
GuictrlRead($antwort2) == $GUI_CHECKED Then
        
If $b == "richtig" Then
            MsgBox
(0"Richtig!""Das war richtig, Glückwunsch!")
            
ExitLoop
        
ElseIf $b == "falsch" Then
            MsgBox
(0"Falsch!""Das war leider falsch")
            Exit
        EndIf
    EndIf
        If 
GuictrlRead($antwort3) == $GUI_CHECKED Then
        
If $c == "richtig" Then
            MsgBox
(0"Richtig!""Das war richtig, Glückwunsch!")
            
ExitLoop
        
ElseIf $c == "falsch" Then
            MsgBox
(0"Falsch!""Das war leider falsch")
            Exit
        EndIf
    EndIf
        If 
GuictrlRead($antwort4) == $GUI_CHECKED Then
        
If $d == "richtig" Then
            MsgBox
(0"Richtig!""Das war richtig, Glückwunsch!")
            
ExitLoop
        
ElseIf $d == "falsch" Then
            MsgBox
(0"Falsch!""Das war leider falsch")
            Exit
        EndIf
    EndIf
EndSwitch

WEnd
$counter
=$counter+1
WEnd
MsgBox
(0"Winner""Nice one"
fragen.au3 (Enthält Variablen / Fragen) :

PHP Code:
Script Start Add your code below here
Global $frage[50], $mantwort1[50], $mantwort2[50], $mantwort3[50], $mantwort4[50], $a[50], $b[50], $c[50], $d[50]
$frage[0]="Mal gucken ob es geht, tut es das?"
$mantwort1[0]="Nene net wirklich"
$mantwort2[0]="Jojo fix"
$mantwort3[0]="Nein"
$mantwort4[0]="Nope2"
$a[0]="falsch"
$b[0]="richtig"
$c[0]="falsch"
$d[0]="falsch"

$frage[1]="Mal gucken ob es geht, tut es das, zweimal?!?"
$mantwort1[1]="Nene net wirklich"
$mantwort2[1]="Jojo fix"
$mantwort3[1]="Nein"
$mantwort4[1]="Nope"
$a[1]="falsch"
$b[1]="richtig"
$c[1]="falsch"
$d[1]="falsch" 
Ich suche jetzt schon seit 2 Stunden nach einer möglichen Lösung und hab keine gefunden.
Hoffe mir kann jemand helfen, so schwer kann das doch nicht sein.

Achja, der Absenden Button muss nicht miteingebaut werden ( das haut sowieso überhaupt nicht hin )

MfG Zim
06/12/2010 00:30 sido47#2
Ähh mach halt einfach

Case $Radio1
Msgbox( Richtig )

oder
if $radio1 = 1 then
MsgBox(Richtig)
Else
Msgbox(Falsch)

stell dir morgen mal ein ganzes Script mit KOda rein
sorry aber bin zu müde um Msgbox Parameter auszuschreibn
06/12/2010 08:33 ddl#3
Schau dir mal dein $a / $b / $c / $d in der Msg While Schleife an...
Da fehlt
Code:
[$counter]
und es muss
Code:
Case $Button1
Sonst funktioniert doch alles....
06/12/2010 10:02 sido47#4
Oh den Fehler mit dem $counter hab ich garned gesehn^^

Hier mal ein Quiz

Quote:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Quiz Window 1/3", 241, 186, 316, 218)
$Label1 = GUICtrlCreateLabel("Wie heisst deine Mutter", 16, 8, 115, 17)
$Radio1 = GUICtrlCreateRadio("Günther", 24, 56, 81, 17)
$Radio2 = GUICtrlCreateRadio("Hildegard", 24, 88, 97, 25)
$Radio3 = GUICtrlCreateRadio("Olaf", 152, 48, 57, 25)
$Radio4 = GUICtrlCreateRadio("Dieter", 152, 88, 73, 25)
$Button1 = GUICtrlCreateButton("LÖSUNG", 80, 136, 81, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $Button1
if GUICtrlRead($Radio2) = 1 then
MsgBox(0,"RICHTIG","Super woher weisst du das blos")
Else
MsgBox(0,"FLASCH","Haha ist deine Mutter ein Mann ?")
EndIf
Exit
EndSwitch
WEnd
06/12/2010 10:07 HardCore.1337#5
naja, ist aber nicht sehr elegant.
Das merkst du vor allem wenn du mehr als eine Frage stellst ;)
06/20/2010 13:09 SuperZim#6
Vielen Dank für die Antworten.

Ein großes Danke für das Scripten eines neues Scripts und ebenfalls für den finden des Fehlers.

Dass ich in meinem Script nur etwas übersehen habe, aber es doch hinbekommen habe find ich natürlich bombastisch xD

Vielen Dank, hat sich somit alles geklärt

MfG Zim