xPloit Posted September 23, 2010 Author Posted September 23, 2010 (edited) okay...I had an idea for the "save/load" function, but I realize that that would require me to use IniRead() functions, which won't work well with _ReadFileToArray() so I gave up on that, lol. But I got everything else done and working perfectly! Here's the entire script: expandcollapse popup#Include <GUIConstants.au3> #Include <File.au3> #Include <Array.au3> AutoItSetOption("MustDeclareVars",1) AutoItSetOption("GUIOnEventMode",1) Global $Correct = 0 Global $Wrong = 0 Dim $aArray Dim $key Dim $Split Global $OpeningGUI = GUICreate("",180,80) GUISetOnEvent($GUI_EVENT_CLOSE,"_Close") Global $File = GUICtrlCreateInput("File name",10,10,160,20) Global $FileDone = GUICtrlCreateButton("Done",60,40,60,30) GUICtrlSetOnEvent($FileDone,"_FileDone") Global $GUI = GUICreate("Flash Card Tester",280,50) GUISetOnEvent($GUI_EVENT_CLOSE,"_Close") Global $StartQuiz = GUICtrlCreateButton("Start Quiz",10,10,70,30) GUICtrlSetOnEvent($StartQuiz,"_Quiz") Global $AddNew = GUICtrlCreateButton("Add New Cards",90,10,90,30) GUICtrlSetOnEvent($AddNew,"_AddNew") Global $Exit = GUICtrlCreateButton("Exit",210,10,50,30) GUICtrlSetOnEvent($Exit,"_Close") Global $AddGUI = GUICreate("Add New",200,100) GUISetOnEvent($GUI_EVENT_CLOSE,"_Close") Global $NewWord = GUICtrlCreateInput("Word",10,10,180,20) Global $NewDef = GUICtrlCreateInput("Definition",10,40,180,20) Global $AddDone = GUICtrlCreateButton("Add",30,70,50,20) GUICtrlSetOnEvent($AddDone,"_AddDone") Global $Return0 = GUICtrlCreateButton("Return",90,70,50,20) GUICtrlSetOnEvent($Return0,"_Return") Global $TestGUI = GUICreate("Flash Card Tester",280,100) GUISetOnEvent($GUI_EVENT_CLOSE,"_Close") Global $Def = GUICtrlCreateInput("",100,8,170,20) Global $CorrectLabel = GUICtrlCreateLabel("Correct -- ",10,20,70,30) Global $Correct = GUICtrlCreateInput("",55,20,30,15) GUICtrlSetState($Correct,$GUI_DISABLE) GUICtrlSetData($Correct,0) Global $WrongLabel = GUICtrlCreateLabel("Wrong -- ",10,45,70,30) Global $Wrong = GUICtrlCreateInput("",55,45,30,15) GUICtrlSetState($Wrong,$GUI_DISABLE) GUICtrlSetData($Wrong,0) Global $PercentageLabel = GUICtrlCreateLabel("% Correct -- ",10,70,150,30) Global $Percentage = GUICtrlCreateInput("",70,70,50,15) GUICtrlSetState($Percentage,$GUI_DISABLE) GUICtrlSetData($Percentage,0) Global $Submit = GUICtrlCreateButton("Show Answer",100,35,170,20) GUICtrlSetOnEvent($Submit,"_ShowAnswer") Global $Return = GUICtrlCreateButton("Return",190,70,80,20) GUICtrlSetOnEvent($Return,"_Return") GUISetState(1,$OpeningGUI) While 1 Sleep(10) WEnd Func _FileDone() If Not FileExists(GUICtrlRead($File)) Then IniWriteSection(GUICtrlRead($File),"Words","") EndIf If Not _FileReadToArray(GUICtrlRead($File), $aArray) Then MsgBox(4096, "Error", "Error reading file to Array" & @CRLF & "error: " & @error) Exit EndIf GUISetState(0,$OpeningGUI) GUISetState(1,$GUI) EndFunc Func _Quiz() GUISetState(0,$GUI) GUISetState(1,$TestGUI) $key = Random(1,$aArray[0],1) $Split = StringSplit($aArray[$key],"=") GUICtrlSetData($Def,$Split[1]) EndFunc Func _AddNew() GUISetState(0,$GUI) GUISetState(1,$AddGUI) EndFunc Func _AddDone() IniWrite(GUICtrlRead($File),"Words",GUICtrlRead($NewWord),GUICtrlRead($NewDef)) GUICtrlSetData($NewWord,"Word") GUICtrlSetData($NewDef,"Definition") TrayTip("Flash Card Tester","Flash card has been added",5) EndFunc Func _Return() GUISetState(0) GUISetState(1,$GUI) EndFunc Func _ShowAnswer() Global $Choice = MsgBox(4,"Answer",$aArray[$key] & @CRLF & @CRLF & "Did you get it right?") If $Choice = 6 Then GUICtrlSetData($Correct,(GUICtrlRead($Correct)+1)) Local $NumCor = ((100*GUICtrlRead($Correct))/(GUICtrlRead($Correct)+GUICtrlRead($Wrong))) Local $CorStr = StringSplit($NumCor,".") GUICtrlSetData($Percentage,$CorStr[1]) $key = Random(1,$aArray[0],1) $Split = StringSplit($aArray[$key],"=") GUICtrlSetData($Def,$Split[1]) ElseIf $Choice = 7 Then GUICtrlSetData($Wrong,(GUICtrlRead($Wrong)+1)) Local $NumWro = ((100*GUICtrlRead($Correct))/(GUICtrlRead($Correct)+GUICtrlRead($Wrong))) Local $WroStr = StringSplit($NumWro,".") GUICtrlSetData($Percentage,$WroStr[1]) $key = Random(1,$aArray[0],1) $Split = StringSplit($aArray[$key],"=") GUICtrlSetData($Def,$Split[1]) EndIf EndFunc Func _Close() Exit EndFunc ***EDIT*** Found an alternative method for save/load. Looks like it will work, but I'm still testing it. I'll post final results after I add, save, load, and test myself on a previous chapter. Edited September 23, 2010 by xPloit 00101101011110000101000001101100011011110110100101110100
xPloit Posted September 23, 2010 Author Posted September 23, 2010 Works well for me. Just added chapter 1 from the same book and it worked perfectly. I did have to make a few changes that I didn't want to do originally, but I guess its fine. The main change is that I cannot have all the word/def pairs in a single .ini file. It creates a new .ini file for each class/chapter and then reads the info from the file you select. Not a big deal. And it works perfectly ^^ Thanks to everyone who helped me along the way to getting this working! I went from having nothing but a GUI to having a fully working program! I learned alot thanks to you guys! 00101101011110000101000001101100011011110110100101110100
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now