SunnBoy Posted March 23, 2010 Share Posted March 23, 2010 (edited) Hey guys, I just started a script for a Spanish Vocabulary learn helper Now i got a little problem with my script. Here it is expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=C:\Users\Marvin\Desktop\Ch1.kxf $Form1 = GUICreate("Chapter 1", 258, 331, 192, 124) $Label = GUICtrlCreateLabel("Chapter 1", 64, 8, 129, 46) GUICtrlSetFont(-1, 18, 400, 0, "Segoe Print") $Label1 = GUICtrlCreateLabel("Spanish to English", 40, 48, 182, 37) GUICtrlSetFont(-1, 14, 400, 0, "Segoe Print") $Label2 = GUICtrlCreateLabel("Word 1", 8, 96, 55, 27) GUICtrlSetFont(-1, 10, 400, 0, "Segoe Print") $Label3 = GUICtrlCreateLabel("Word 2", 8, 136, 55, 27) GUICtrlSetFont(-1, 10, 400, 0, "Segoe Print") $Label4 = GUICtrlCreateLabel("Word 3", 8, 176, 55, 27) GUICtrlSetFont(-1, 10, 400, 0, "Segoe Print") $Input1 = GUICtrlCreateInput("", 112, 96, 121, 21) $Input2 = GUICtrlCreateInput("", 112, 136, 121, 21) $Input3 = GUICtrlCreateInput("", 112, 176, 121, 21) $Button1 = GUICtrlCreateButton("Submit Answers", 48, 216, 139, 73, $WS_GROUP) $Read1 = GUICtrlRead ($Input1) $Read2 = GUICtrlRead ($Input2) $Read3 = GUICtrlRead ($Input3) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Submit_Answers () EndSwitch WEnd Func Submit_Answers () $Read1 = GUICtrlRead ($Input1) IniWrite ("Chapter1.ini","section1","Word1",$Read1) $Read2 = GUICtrlRead ($Input2) IniWrite ("Chapter1.ini","section2","Word2",$Read2) $Read3 = GUICtrlRead ($Input3) IniWrite ("Chapter1.ini","section3","Word3",$Read3) $var = IniRead ("Ch1Answers.ini","section1","Word1","") + IniRead ("Ch1Answers.ini","section2","Word2","") If $var = $Read1 then MsgBox (0,"Right","Correct Answer") Else MsgBox (0,"Wrong","Wrong Answer") EndIf EndFunc Now i have the file Ch1Answers.ini in my folder. I want the script when someone puts the answers in to check the Answers file if the entered words are correct. That worked fine, but then I added the part + IniRead ("Ch1Answers.ini","section2","Word2","") so i thought the script would check section2 also. But its not really working maybe you guys can help me. Would I have to do a If $var = $Read1 then MsgBox (0,"Right","Correct Answer") Else MsgBox (0,"Wrong","Wrong Answer") EndIf EndFunc for every Word? Or can i just put one for all? Thanks Edited March 23, 2010 by SunnBoy Link to comment Share on other sites More sharing options...
somdcomputerguy Posted March 23, 2010 Share Posted March 23, 2010 (edited) Read the file once, with _FileReadToArray. Edited March 23, 2010 by snowmaker - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
SunnBoy Posted March 23, 2010 Author Share Posted March 23, 2010 Thanks for the reply but i don't really now how reading it into an array could help me with it lol Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 24, 2010 Moderators Share Posted March 24, 2010 SunnBoy, Does this help? I am assuming that you get your 3 answers from 3 ini files to match the IniWrite ones. If you want to check all 3 at once, you need to concatenate the 3 responses and the the 3 answers like this: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #region ### START Koda GUI section ### Form=C:\Users\Marvin\Desktop\Ch1.kxf $Form1 = GUICreate("Chapter 1", 258, 331, 192, 124) $Label = GUICtrlCreateLabel("Chapter 1", 64, 8, 129, 46) GUICtrlSetFont(-1, 18, 400, 0, "Segoe Print") $Label1 = GUICtrlCreateLabel("Spanish to English", 40, 48, 182, 37) GUICtrlSetFont(-1, 14, 400, 0, "Segoe Print") $Label2 = GUICtrlCreateLabel("Word 1", 8, 96, 55, 27) GUICtrlSetFont(-1, 10, 400, 0, "Segoe Print") $Label3 = GUICtrlCreateLabel("Word 2", 8, 136, 55, 27) GUICtrlSetFont(-1, 10, 400, 0, "Segoe Print") $Label4 = GUICtrlCreateLabel("Word 3", 8, 176, 55, 27) GUICtrlSetFont(-1, 10, 400, 0, "Segoe Print") $Input1 = GUICtrlCreateInput("", 112, 96, 121, 21) $Input2 = GUICtrlCreateInput("", 112, 136, 121, 21) $Input3 = GUICtrlCreateInput("", 112, 176, 121, 21) $Button1 = GUICtrlCreateButton("Submit Answers", 48, 216, 139, 73, $WS_GROUP) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Submit_Answers() EndSwitch WEnd Func Submit_Answers() $Read1 = GUICtrlRead($Input1) IniWrite("Chapter1.ini", "section1", "Word1", $Read1) $Read2 = GUICtrlRead($Input2) IniWrite("Chapter1.ini", "section2", "Word2", $Read2) $Read3 = GUICtrlRead($Input3) IniWrite("Chapter1.ini", "section3", "Word3", $Read3) ; Concatenate the responses $Response = $Read1 & $Read2 & $Read3 ; Concatenate the answers $var = IniRead("Ch1Answers.ini", "section1", "Word1", "") & _ IniRead("Ch1Answers.ini", "section2", "Word2", "") & _ IniRead("Ch1Answers.ini", "section3", "Word3", "") ; If all correct say so If $var = $Response Then MsgBox(0, "Right", "Correct Answer") Else MsgBox(0, "Wrong", "Wrong Answer") EndIf EndFunc ;==>Submit_Answers I hope that helps. If not, please post some truncated ini files so we can see the structure a bit better. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
SunnBoy Posted March 24, 2010 Author Share Posted March 24, 2010 Hey thanks M23 That's exactly what I was looking for sorry I answered so late lol just got home ^^ Thank you so much for your help Sunn Link to comment Share on other sites More sharing options...
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