zwierzak Posted July 16, 2010 Share Posted July 16, 2010 (edited) Hello. I'm working on a new project but I have met a problem. My program is made of 1 combo box and few inputs. The thing is, when i pick an option from combo box, data should be placed into inputs - different data for each combo box item. Do you know what i mean? I have sucessfully done it with inputs in the first group, but I have to do it with few others("Cele ataku" group) - there i have to use string split cause it's written into .ini file like that: IniWrite("config.ini","villages","village" & $x, Guictrlread($input1) & "\" & GuiCtrlRead($Input2)) So in ini file it looks like that: [village] village1=11\22 I have to admit that in the inputs there only may be numbers, no letters. There could be x number of new villages, so It's obvious to use loop to make this, but don't know how to do it ;/ Here is what I've done so far. Please help me to solve this problem. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### $Form1 = GUICreate("form1", 658, 441, 432, 160) $Tab1 = GUICtrlCreateTab(0, 8, 657, 393) GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $TabSheet1 = GUICtrlCreateTabItem("Farmienie") $add = GUICtrlCreateButton("Dodaj wioskÄ™", 144, 40, 75, 25, $WS_GROUP) $wioska = GUICtrlCreateCombo("", 480, 40, 145, 25) $nazwa = GUICtrlCreateInput("", 16, 40, 121, 21) $Group1 = GUICtrlCreateGroup("Jednostki", 16, 88, 625, 137) $pik = GUICtrlCreateInput("", 64, 112, 65, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER)) $miecz = GUICtrlCreateInput("", 64, 136, 65, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER)) $topor = GUICtrlCreateInput("", 64, 160, 65, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER)) $luk = GUICtrlCreateInput("", 64, 184, 65, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER)) $zwiad = GUICtrlCreateInput("", 208, 112, 65, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER)) $lekka = GUICtrlCreateInput("", 208, 136, 65, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER)) $klucznik = GUICtrlCreateInput("", 208, 160, 65, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER)) $ciezka = GUICtrlCreateInput("", 208, 184, 65, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER)) $taran = GUICtrlCreateInput("", 360, 112, 65, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER)) $kata = GUICtrlCreateInput("", 360, 136, 65, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER)) $rycek = GUICtrlCreateInput("", 504, 112, 65, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER)) $szlachta = GUICtrlCreateInput("", 504, 136, 65, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER)) $Pic1 = GUICtrlCreatePic("D:\Projekty autoit\Projekty\Plemiona\1.JPG", 40, 112, 0, 0) $Pic2 = GUICtrlCreatePic("D:\Projekty autoit\Projekty\Plemiona\2.JPG", 40, 136, 0, 0) $Pic3 = GUICtrlCreatePic("D:\Projekty autoit\Projekty\Plemiona\3.JPG", 40, 160, 0, 0) $Pic4 = GUICtrlCreatePic("D:\Projekty autoit\Projekty\Plemiona\4.JPG", 40, 184, 0, 0) $Pic5 = GUICtrlCreatePic("D:\Projekty autoit\Projekty\Plemiona\5.JPG", 184, 112, 0, 0) $Pic6 = GUICtrlCreatePic("D:\Projekty autoit\Projekty\Plemiona\6.JPG", 184, 136, 0, 0) $Pic7 = GUICtrlCreatePic("D:\Projekty autoit\Projekty\Plemiona\7.JPG", 184, 160, 0, 0) $Pic8 = GUICtrlCreatePic("D:\Projekty autoit\Projekty\Plemiona\8.JPG", 184, 184, 0, 0) $Pic9 = GUICtrlCreatePic("D:\Projekty autoit\Projekty\Plemiona\9.JPG", 336, 112, 0, 0) $Pic10 = GUICtrlCreatePic("D:\Projekty autoit\Projekty\Plemiona\10.JPG", 336, 136, 0, 0) $Pic11 = GUICtrlCreatePic("D:\Projekty autoit\Projekty\Plemiona\11.JPG", 480, 112, 0, 0) $Pic12 = GUICtrlCreatePic("D:\Projekty autoit\Projekty\Plemiona\12.JPG", 480, 136, 0, 0) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("Cele ataku", 16, 232, 625, 161) $1a = GUICtrlCreateInput("", 64, 264, 33, 21) $1b = GUICtrlCreateInput("", 112, 264, 33, 21) $2a = GUICtrlCreateInput("", 64, 288, 33, 21) $2b = GUICtrlCreateInput("", 112, 288, 33, 21) $3a = GUICtrlCreateInput("", 64, 312, 33, 21) $3b = GUICtrlCreateInput("", 112, 312, 33, 21) $4a = GUICtrlCreateInput("", 64, 336, 33, 21) $4b = GUICtrlCreateInput("", 112, 336, 33, 21) $5a = GUICtrlCreateInput("", 64, 360, 33, 21) $5b = GUICtrlCreateInput("", 112, 360, 33, 21) $6a = GUICtrlCreateInput("", 296, 264, 33, 21) $6b = GUICtrlCreateInput("", 344, 264, 33, 21) $7a = GUICtrlCreateInput("", 296, 288, 33, 21) $7b = GUICtrlCreateInput("", 344, 288, 33, 21) $8a = GUICtrlCreateInput("", 296, 312, 33, 21) $8b = GUICtrlCreateInput("", 344, 312, 33, 21) $9a = GUICtrlCreateInput("", 296, 336, 33, 21) $9b = GUICtrlCreateInput("", 344, 336, 33, 21) $10a = GUICtrlCreateInput("", 296, 360, 33, 21) $10b = GUICtrlCreateInput("", 344, 360, 33, 21) $Label4 = GUICtrlCreateLabel("|", 104, 264, 6, 17) $Label5 = GUICtrlCreateLabel("|", 104, 288, 6, 17) $Label6 = GUICtrlCreateLabel("|", 104, 312, 6, 17) $Label7 = GUICtrlCreateLabel("|", 104, 336, 6, 17) $Label8 = GUICtrlCreateLabel("|", 104, 360, 6, 17) $Label9 = GUICtrlCreateLabel("|", 336, 264, 6, 17) $Label10 = GUICtrlCreateLabel("|", 336, 288, 6, 17) $Label11 = GUICtrlCreateLabel("|", 336, 312, 6, 17) $Label12 = GUICtrlCreateLabel("|", 336, 336, 6, 17) $Label13 = GUICtrlCreateLabel("|", 336, 360, 6, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateTabItem("") $Start = GUICtrlCreateButton("Start", 48, 408, 75, 25, $WS_GROUP) $Save = GUICtrlCreateButton("Zapisz", 148, 408, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### loadingdata() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Save For $m = 1 To IniRead("config.ini", "liczba wiosek", "licznik", "") -1 Step +1 If GUICtrlRead($wioska) = IniRead("config.ini", "wioski", "wioska" & $m, "") Then IniWrite("config.ini", "wioska" & $m, "pik", GUICtrlRead($pik)) IniWrite("config.ini", "wioska" & $m, "miecz", GUICtrlRead($miecz)) IniWrite("config.ini", "wioska" & $m, "topor", GUICtrlRead($topor)) IniWrite("config.ini", "wioska" & $m, "luk", GUICtrlRead($luk)) IniWrite("config.ini", "wioska" & $m, "zwiad", GUICtrlRead($zwiad)) IniWrite("config.ini", "wioska" & $m, "lekka", GUICtrlRead($lekka)) IniWrite("config.ini", "wioska" & $m, "klucznik", GUICtrlRead($klucznik)) IniWrite("config.ini", "wioska" & $m, "ciezka", GUICtrlRead($ciezka)) IniWrite("config.ini", "wioska" & $m, "taran", GUICtrlRead($taran)) IniWrite("config.ini", "wioska" & $m, "kata", GUICtrlRead($kata)) IniWrite("config.ini", "wioska" & $m, "rycek", GUICtrlRead($rycek)) IniWrite("config.ini", "wioska" & $m, "szlachta", GUICtrlRead($szlachta)) ;it has been saved for only 1 village, need to make save for x number of villages, the only chaning thing is $m IniWrite("config.ini", "wioska" & $m, "1atak", GUICtrlRead($1a) & "\" & GUICtrlRead($1b)) IniWrite("config.ini", "wioska" & $m, "2atak", GUICtrlRead($2a) & "\" & GUICtrlRead($2b)) IniWrite("config.ini", "wioska" & $m, "3atak", GUICtrlRead($3a) & "\" & GUICtrlRead($3b)) IniWrite("config.ini", "wioska" & $m, "4atak", GUICtrlRead($4a) & "\" & GUICtrlRead($4b)) IniWrite("config.ini", "wioska" & $m, "5atak", GUICtrlRead($5a) & "\" & GUICtrlRead($5b)) IniWrite("config.ini", "wioska" & $m, "6atak", GUICtrlRead($6a) & "\" & GUICtrlRead($6b)) IniWrite("config.ini", "wioska" & $m, "7atak", GUICtrlRead($7a) & "\" & GUICtrlRead($7b)) IniWrite("config.ini", "wioska" & $m, "8atak", GUICtrlRead($8a) & "\" & GUICtrlRead($8b)) IniWrite("config.ini", "wioska" & $m, "9atak", GUICtrlRead($9a) & "\" & GUICtrlRead($9b)) IniWrite("config.ini", "wioska" & $m, "10atak", GUICtrlRead($10a) & "\" & GUICtrlRead($10b)) EndIf Next Case $Start Case $add newvillage() Case $wioska For $m = 1 To IniRead("config.ini", "liczba wiosek", "licznik", "") -1 Step +1 If GUICtrlRead($wioska) = IniRead("config.ini", "wioski", "wioska" & $m, "") Then GUICtrlSetData($pik, IniRead("config.ini", "wioska" & $m, "pik", "")) GUICtrlSetData($miecz, IniRead("config.ini", "wioska" & $m, "miecz", "")) GUICtrlSetData($topor, IniRead("config.ini", "wioska" & $m, "topor", "")) GUICtrlSetData($luk, IniRead("config.ini", "wioska" & $m, "luk", "")) GUICtrlSetData($zwiad, IniRead("config.ini", "wioska" & $m, "zwiad", "")) GUICtrlSetData($lekka, IniRead("config.ini", "wioska" & $m, "lekka", "")) GUICtrlSetData($klucznik, IniRead("config.ini", "wioska" & $m, "klucznik", "")) GUICtrlSetData($ciezka, IniRead("config.ini", "wioska" & $m, "ciezka", "")) GUICtrlSetData($taran, IniRead("config.ini", "wioska" & $m, "taran", "")) GUICtrlSetData($kata, IniRead("config.ini", "wioska" & $m, "kata", "")) GUICtrlSetData($rycek, IniRead("config.ini", "wioska" & $m, "rycek", "")) GUICtrlSetData($szlachta, IniRead("config.ini", "wioska" & $m, "szlachta", "")) ;It should me made like this but for x number of villages - not one ; GUICtrlSetData($1a, $c[0] = StringSplit(IniRead("config.ini", "wioska" & $m, "1atak", ""), "|")) ; GUICtrlSetData($1b, $c[1] = StringSplit(IniRead("config.ini", "wioska" & $m, "1atak", ""), "|")) ; GUICtrlSetData($2a, StringSplit(IniRead("config.ini", "wioska" & $m, "2atak", ""), "|")) ; GUICtrlSetData($2b, StringSplit(IniRead("config.ini", "wioska" & $m, "2atak", ""), "|")) ; GUICtrlSetData($3a, StringSplit(IniRead("config.ini", "wioska" & $m, "3atak", ""), "|")) ; GUICtrlSetData($3b, StringSplit(IniRead("config.ini", "wioska" & $m, "3atak", ""), "|")) ; GUICtrlSetData($4a, StringSplit(IniRead("config.ini", "wioska" & $m, "4atak", ""), "|")) ; GUICtrlSetData($4b, StringSplit(IniRead("config.ini", "wioska" & $m, "4atak", ""), "|")) ; GUICtrlSetData($5a, StringSplit(IniRead("config.ini", "wioska" & $m, "5atak", ""), "|")) ; GUICtrlSetData($5b, StringSplit(IniRead("config.ini", "wioska" & $m, "5atak", ""), "|")) ; GUICtrlSetData($6a, StringSplit(IniRead("config.ini", "wioska" & $m, "6atak", ""), "|")) ; GUICtrlSetData($6b, StringSplit(IniRead("config.ini", "wioska" & $m, "6atak", ""), "|")) ; GUICtrlSetData($7a, StringSplit(IniRead("config.ini", "wioska" & $m, "7atak", ""), "|")) ; GUICtrlSetData($7b, StringSplit(IniRead("config.ini", "wioska" & $m, "7atak", ""), "|")) ; GUICtrlSetData($8a, StringSplit(IniRead("config.ini", "wioska" & $m, "8atak", ""), "|")) ; GUICtrlSetData($8b, StringSplit(IniRead("config.ini", "wioska" & $m, "8atak", ""), "|")) ; GUICtrlSetData($9a, StringSplit(IniRead("config.ini", "wioska" & $m, "9atak", ""), "|")) ; GUICtrlSetData($9b, StringSplit(IniRead("config.ini", "wioska" & $m, "9atak", ""), "|")) ; GUICtrlSetData($10a, StringSplit(IniRead("config.ini", "wioska" & $m, "10atak", ""), "|")) ; GUICtrlSetData($10b, StringSplit(IniRead("config.ini", "wioska" & $m, "10atak", ""), "|")) EndIf Next EndSwitch WEnd Func loadingdata() If FileExists(@ScriptDir & "\config.ini") Then If IniRead("config.ini", "liczba wiosek", "licznik", "") = Not @error Then For $zmienna1 = 1 To IniRead("config.ini", "liczba wiosek", "licznik", "") -1 Step +1 GUICtrlSetData($wioska, IniRead("config.ini", "wioski", "wioska" & $zmienna1, "")) Next EndIf EndIf EndFunc ;==>loadingdata Func newvillage() If IniRead("config.ini", "liczba wiosek", "licznik", "") = @error Then $licznik = 1 Else $licznik = IniRead("config.ini", "liczba wiosek", "licznik", "") EndIf $data = StringReplace(GUICtrlRead($nazwa), "|", "\") GUICtrlSetData($wioska, $data) IniWrite("config.ini", "wioski", "wioska" & $licznik, $data) $licznik = $licznik + 1 IniWrite("config.ini", "liczba wiosek", "licznik", $licznik) EndFunc ;==>newvillage Edited July 16, 2010 by zwierzak Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 16, 2010 Moderators Share Posted July 16, 2010 zwierzak,Two reasons why your StringSplit is not working:- 1. You create the ini entry usingIniWrite("config.ini", "wioska" & $m, "1atak", GUICtrlRead($1a) & "\" & GUICtrlRead($1b))but you are trying to split it usingStringSplit(IniRead("config.ini", "wioska" & $m, "1atak", ""), "|"))You need to use the same delimiter! - 2. Your GUICtrlSetData($1a, $c[0] = StringSplit(...) syntax is all wrong. If you look in the Help file, you will see that StringSplit returns an array - so you must get that first and then use the individual elements to fill the inputs. So you need code that looks like this:$aSplitData = StringSplit(IniRead("config.ini", "wioska" & $m, "1atak", ""), "\") GUICtrlSetData($1a, $aSplitData[1]) GUICtrlSetData($1b, $aSplitData[2])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...
zwierzak Posted July 16, 2010 Author Share Posted July 16, 2010 (edited) Everything is ok, but how to use For...Next loop in here? Because there might be a lot of different villages, so I can't write it manually. I just don't get it ^^ Sorry for being annoying for you guys, but I'm not an advanced scripter. For me it should look something like this, but ... it doesn't work For $liczba = 1 to 10 Step +1 $stringSplit = StringSplit(IniRead("config.ini", "wioska" & $liczba, $liczba & "atak", ""), "\") GUICtrlSetData($liczba & "a", $stringSplit[1] = StringSplit(IniRead("config.ini", "wioska" & $liczba,$liczba & "atak", ""), "\")) GUICtrlSetData($liczba & "b", $stringSplit[2] = StringSplit(IniRead("config.ini", "wioska" & $liczba,$liczba & "atak", ""), "\")) Next Edited July 16, 2010 by zwierzak Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 16, 2010 Moderators Share Posted July 16, 2010 zwierzak,As I said above, you get the array first and then use the elements - you do not need to call StringSplit each time: For $liczba = 1 to 10 ; Step +1 Not required as that is the default setting <<<<<<<<<<<<<<<< $stringSplit = StringSplit(IniRead("config.ini", "wioska" & $liczba, $liczba & "atak", ""), "\") ; Get the elements into an array <<<<<<<<<<<< GUICtrlSetData($liczba & "a", $stringSplit[1]) ; Use the individual elements of the array <<<<<<<<<<<<<<<<<<< GUICtrlSetData($liczba & "b", $stringSplit[2]) ; Use the individual elements of the array <<<<<<<<<<<<<<<<<<< NextIf you are not very happy with arrays, there is a tutorial in the Wiki which you might want to read. 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...
zwierzak Posted July 16, 2010 Author Share Posted July 16, 2010 OMG ^^ I hate arrays. What the hell? ;/ (168) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: in this line: GUICtrlSetData($liczba & "b", $stringSplit[2]) ; Use the individual elements of the array <<<<<<<<<<<<<<<<<<< When i use [0] and in the next line [1] then it works but doesn't load any data ^^ so there must be error in stringsplit Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 16, 2010 Moderators Share Posted July 16, 2010 zwierzak, The error is telling you that $stringSplit[2] does not exist. This is almost certainly because StringSplit did not find the delimiter in the value recovered from the Ini file. You need to put in some error checking to make sure that there are 2 values - like this: ; Just for testing, let us look at the value - you can delete this later MsgBox(0, "Test", IniRead("config.ini", "wioska" & $liczba, $liczba & "atak", "") $stringSplit = StringSplit(IniRead("config.ini", "wioska" & $liczba, $liczba & "atak", ""), "\") If $stringSplit[0] = 2 Then ; Check that we have at leaset 2 elements before we try to access them <<<<<<<<<<<<<<< GUICtrlSetData($liczba & "a", $stringSplit[1]) GUICtrlSetData($liczba & "b", $stringSplit[2]) EndIf I hate arraysDid you look at that tutorial I suggested? Arrays are a fundamental part of coding - you really do need to understand them. 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...
zwierzak Posted July 16, 2010 Author Share Posted July 16, 2010 I'm reading the article at the moment. I will check if there is enough elements, but when i look in ini file it looks ok. [village] village1=11\22 It should work Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 16, 2010 Moderators Share Posted July 16, 2010 zwierzak, That is why we need errorchecking code as I suggested above to make sure that the code is actually reading the correct values from the Inifile. 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...
zwierzak Posted July 16, 2010 Author Share Posted July 16, 2010 (edited) But it reades correctly ;////EDITSorry, it doesn't read correctly. Reads only first "atak" called "1atak" rest is empty. Any suggestions why?///EDIT 2I found a mistake, but it hasn't changed anything.However, I will explain it here maybe it will help to solve the big problem.For $liczba = 1 to 10 ; Step +1 Not required as that is the default setting <<<<<<<<<<<<<<<< $stringSplit = StringSplit(IniRead("config.ini", "wioska" & $liczba, $liczba & "atak", ""), "\") ; Get the elements into an array <<<<<<<<<<<< GUICtrlSetData($liczba & "a", $stringSplit[1]) ; Use the individual elements of the array <<<<<<<<<<<<<<<<<<< GUICtrlSetData($liczba & "b", $stringSplit[2]) ; Use the individual elements of the array <<<<<<<<<<<<<<<<<<< Next$stringSplit = StringSplit(IniRead("config.ini", "wioska" & $liczba, $liczba & "atak", ""), "\")$liczba would grow up to 10, but there aren't 10 villages. In my script i made something like "counter" which counts how many villages are there (-1) so new script looks like this:For $liczba = 1 To 10 $data1 = 1 MsgBox(0, "Test", IniRead("config.ini", "wioska" & $liczba, $liczba & "atak", "")) $stringSplit = StringSplit(IniRead("config.ini", "wioska" & $data, $liczba & "atak", ""), "\") If $stringSplit[0] = 2 Then ; Check that we have at leaset 2 elements before we try to access them <<<<<<<<<<<<<<< GUICtrlSetData($liczba & "a", $stringSplit[1]) GUICtrlSetData($liczba & "b", $stringSplit[2]) EndIf If $data1 < IniRead("config.ini", "liczba wiosek", "licznik", "") -1 Then $data1 = $data1 + 1 EndIf Next Edited July 16, 2010 by zwierzak Link to comment Share on other sites More sharing options...
GEOSoft Posted July 16, 2010 Share Posted July 16, 2010 The next thing you should read is Ubound() and probably IniReadSection() When the amount of entries could change, such as yours have, it is much better to use Ubound($aSection)-1 than a specific number like 10. It avoids problems like you have now. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 16, 2010 Moderators Share Posted July 16, 2010 zwierzak,Instead of using IniRead in your loop, just do it once before you start and use that as the count: ; get your count $data = IniRead("config.ini", "liczba wiosek", "licznik", "") - 1 ; Now loop that number of times For $liczba = 1 To $data MsgBox(0, "Test", IniRead("config.ini", "wioska" & $liczba, $liczba & "atak", "")) $stringSplit = StringSplit(IniRead("config.ini", "wioska" & $data, $liczba & "atak", ""), "\") If $stringSplit[0] = 2 Then ; Check that we have at leaset 2 elements before we try to access them <<<<<<<<<<<<<<< GUICtrlSetData($liczba & "a", $stringSplit[1]) GUICtrlSetData($liczba & "b", $stringSplit[2]) EndIf NextM23  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...
GEOSoft Posted July 16, 2010 Share Posted July 16, 2010 (edited) $data = IniRead("config.ini", "liczba wiosek", "licznik", "") - 1?????????????????????????????????Weak moment? Edited July 16, 2010 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 17, 2010 Moderators Share Posted July 17, 2010 George, Looking at it again you are probably right, but I was losing the will to live by that stage - and had to rush out to the airport to meet someone. Well, that is my excuse anyway! 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...
GEOSoft Posted July 17, 2010 Share Posted July 17, 2010 Stick with that excuse, most people will just sit there for hours trying to see what's wrong so you'll get away with it. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" 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