Jump to content

Recommended Posts

Posted (edited)

For some reason something in this script dosn't work, I can't tell what... It starts up ok tho. This is a program to have a GUI quiz you about the elements. It can be set on what to quiz you on, right now it is set to the element's symbols only. The part that's not working is when you click on submit, it does nothing.

Global $msg, $idle
Dim $stats[2] = [0, 0]
$eName = StringSplit("Sulfur,Iron,Barium,Tin,Phosphorus,Noen,Lithium,Potassium,Hydrogen,Helium,Carbon,Nitrogen,Oxygen,


Sodium,Aluminum,Silver,Chlorine,Calcium,Copper,Gold,Zinc,Lead,Magnesium,Nickle,Boron,Arsenic,Mercury


,Fluorine", ",")
$eSymbol = StringSplit("S,Fe,Ba,Sn,P,Ne,Lu,K,H,He,C,N,O,Na,Al,Ag,Cl,Ca,Cu,Au,Zn,Pb,Mg,Ni,B,As,Hg,F", ",")
$eAtomicNumber = StringSplit("16,26,56,50,15,10,3,19,1,2,6,7,8,11,13,47,17,20,29,79,30,82,12,28,5,33,80,9", ",")
$eAtomicMass = StringSplit("32,56,137,119,31,20,7,39,1,4,12,14,16,23,27,108,35,40,64,197,65,209,24,59,11,75,201,19", ",")
AdlibEnable("ChangeIdle", 500)
GUICreate("Element FlashCards", 275, 330, (@DesktopWidth - 275) / 2, (@DesktopHeight - 330) / 2, 0x10CF0000)
GUICtrlCreateLabel("What belongs where the ""??"" is?", 30, 240, 100, 30)
$Name = GUICtrlCreateLabel("Name", 100, 100, 70, 20, 1)
$Symbol = GUICtrlCreateLabel("Sy", 120, 60, 20, 20, 1)
$Number = GUICtrlCreateLabel("A#", 210, 10, 70, 20, 1)
$Mass = GUICtrlCreateLabel("M#", 120, 140, 30, 20, 1)
$Input = GUICtrlCreateInput("", 150, 230, 100, 20)
$IdlePic = GUICtrlCreateLabel("\", 10, 10, Default, Default)
$Submit = GUICtrlCreateButton("Submit", 170, 260, Default, Default, 512)
$Answer = ChangeLables(Random(1, 28, 1), Random(1, 1, 1))

While True
    $msg = GUIGetMsg()
    Select
        Case $msg = 0
            ContinueLoop
        Case $msg = -3
            ExitLoop
        Case $msg = $Submit
            If $Answer == GUICtrlRead($Input)Then
                $tooltip = "Correct!  It was """ & $Answer & """!"
                $stats[1] += 1
            Else
                $tooltip = "Sorry.  """ & $Answer & """ was answer."
            EndIf
            $stats[0] += 1
            $tooltip &= @CRLF & @CRLF & $stats[0] & "/" & $stats[1] & " (" & Round($stats[1] / $stats[0], 1) & "%)"
            ToolTip($tooltip, 10, 10)
            $Answer = ChangeLables(Random(1, 28, 1), Random(1, 1, 1))
    EndSelect
WEnd

Func ChangeIdle()
    Select
        Case $idle = 0
            GUICtrlSetData($IdlePic, "|")
            $idle = 1
        Case $idle = 1
            GUICtrlSetData($IdlePic, "/")
            $idle = 2
        Case $idle = 2
            GUICtrlSetData($IdlePic, "-")
            $idle = 3
        Case $idle = 3
            GUICtrlSetData($IdlePic, "\")
            $idle = 0
    EndSelect
EndFunc;==>ChangeIdle

Func ChangeLables($num, $quiz)
    $quiz = Quiz($num, $quiz)
    GUICtrlSetData($Name, $quiz[0])
    GUICtrlSetData($Symbol, $quiz[1])
    GUICtrlSetData($Number, $quiz[2])
    GUICtrlSetData($Mass, $quiz[3])
    GUICtrlSetData($Input, "")
    GUICtrlSetState($Input, 256)
    Return $quiz[4]
EndFunc;==>ChangeLables

Func Quiz($num, $quiz)
    Dim $return[5]
    $return[0] = $eName[$num]
    $return[1] = $eSymbol[$num]
    $return[2] = $eAtomicNumber[$num]
    $return[3] = $eAtomicMass[$num]
    $return[4] = $return[$quiz]
    $return[$quiz] = "??"
    Return $return
EndFunc;==>Quiz
Any/All comments accepted.

(I hate remembering those symbols :P)

Edited by gamerman2360
Posted (edited)

Fixed a few things here:

Global $msg, $idle
Dim $stats[2] = [0, 0]
$eName = StringSplit("Sulfur,Iron,Barium,Tin,Phosphorus,Neon,Lithium,Potassium,Hydrogen,Helium,Carbon,Nitrogen,Oxygen,


Sodium,Aluminum,Silver,Chlorine,Calcium,Copper,Gold,Zinc,Lead,Magnesium,Nickle,Boron,Arsenic,Mercury


,Fluorine", ",")
$eSymbol = StringSplit("S,Fe,Ba,Sn,P,Ne,Lu,K,H,He,C,N,O,Na,Al,Ag,Cl,Ca,Cu,Au,Zn,Pb,Mg,Ni,B,As,Hg,F", ",")
$eAtomicNumber = StringSplit("16,26,56,50,15,10,3,19,1,2,6,7,8,11,13,47,17,20,29,79,30,82,12,28,5,33,80,9", ",")
$eAtomicMass = StringSplit("32,56,137,119,31,20,7,39,1,4,12,14,16,23,27,108,35,40,64,197,65,209,24,59,11,75,201,19", ",")
AdlibEnable("ChangeIdle", 500)
GUICreate("Element FlashCards", 275, 330, (@DesktopWidth - 275) / 2, (@DesktopHeight - 330) / 2, 0x10CF0000)
GUICtrlCreateLabel("What belongs where the ""??"" is?", 30, 240, 100, 30)
$Name = GUICtrlCreateLabel("Name", 100, 100, 70, 20, 1)
$Symbol = GUICtrlCreateLabel("Sy", 120, 60, 20, 20, 1)
$Number = GUICtrlCreateLabel("A#", 210, 10, 70, 20, 1)
$Mass = GUICtrlCreateLabel("M#", 120, 140, 30, 20, 1)
$Input = GUICtrlCreateInput("", 150, 230, 100, 20)
$IdlePic = GUICtrlCreateLabel("\", 10, 10, Default, Default)
$Submit = GUICtrlCreateButton("Submit", 170, 260, Default, Default, 1)
$Answer = ChangeLables(Random(1, 28, 1), Random(1, 1, 1))

While True
    $msg = GUIGetMsg()
    Select
        Case $msg = 0
            ContinueLoop
        Case $msg = -3
            ExitLoop
        Case $msg = $Submit
            If $Answer == GUICtrlRead($Input)Then
                $tooltip = "Correct!  It was """ & $Answer & """!"
                $stats[1] += 1
            Else
                $tooltip = "Sorry.  """ & $Answer & """ was answer."
            EndIf
            $stats[0] += 1
            $tooltip &= @CRLF & @CRLF & $stats[1] & "/" & $stats[0] & Grade(Round($stats[1] / $stats[0], 3)*100)
            ToolTip($tooltip, 10, 10)
            $Answer = ChangeLables(Random(1, 28, 1), Random(1, 1, 1))
    EndSelect
WEnd

Func ChangeIdle()
    Select
        Case $idle = 0
            GUICtrlSetData($IdlePic, "|")
            $idle = 1
        Case $idle = 1
            GUICtrlSetData($IdlePic, "/")
            $idle = 2
        Case $idle = 2
            GUICtrlSetData($IdlePic, "-")
            $idle = 3
        Case $idle = 3
            GUICtrlSetData($IdlePic, "\")
            $idle = 0
    EndSelect
EndFunc;==>ChangeIdle

Func ChangeLables($num, $quiz)
    $quiz = Quiz($num, $quiz)
    GUICtrlSetData($Name, $quiz[0])
    GUICtrlSetData($Symbol, $quiz[1])
    GUICtrlSetData($Number, $quiz[2])
    GUICtrlSetData($Mass, $quiz[3])
    GUICtrlSetData($Input, "")
    GUICtrlSetState($Input, 256)
    Return $quiz[4]
EndFunc;==>ChangeLables

Func Quiz($num, $quiz)
    Dim $return[5]
    $return[0] = $eName[$num]
    $return[1] = $eSymbol[$num]
    $return[2] = $eAtomicNumber[$num]
    $return[3] = $eAtomicMass[$num]
    $return[4] = $return[$quiz]
    $return[$quiz] = "??"
    Return $return
EndFunc;==>Quiz

Func Grade($percent)
    If $percent > 92 Then
        $grade = "A"
    ElseIf $percent > 82 Then
        $grade = "B"
    ElseIf $percent > 70 Then
        $grade = "C"
    ElseIf $percent > 60 Then
        $grade = "D"
    Else
        $grade = "F"
    EndIf
    Return " (" & $percent & "% " & $grade & ")"
EndFunc

Edited by gamerman2360

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...