Swift Posted April 5, 2008 Posted April 5, 2008 It say's subscript used with non-array variable. I need these to be a array, so I can use a For/Next loop to set the data of the Inputs. Check out my code. My goal is load the info from the ini, into the Listbox, and then the inputs. expandcollapse popup#include <GUIConstants.au3> #include <GUIListBox.au3> Global $INI=@ScriptDir&"\ini.ini" #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Swift's AutoIt Meal Planner", 609, 308) $Date1 = GUICtrlCreateDate("2008/04/04 20:48:41", 0, 0, 210, 21) $List1 = GUICtrlCreateList("", 0, 24, 209, 253) $Button1 = GUICtrlCreateButton("New Meal", 0, 280, 73, 25, 0) $Button2 = GUICtrlCreateButton("Delete Meal", 80, 280, 75, 25, 0) $Button3 = GUICtrlCreateButton("Edit", 160, 280, 51, 25, 0) $Label1 = GUICtrlCreateLabel("Meal Planner Information", 360, 0, 137, 17) $Input[1] = GUICtrlCreateInput("", 224, 24, 121, 21) $Label2 = GUICtrlCreateLabel("Meal Name", 224, 8, 58, 17) $Input[2] = GUICtrlCreateInput("", 224, 64, 121, 21) $Label3 = GUICtrlCreateLabel("Meal Time", 224, 48, 53, 17) $Label4 = GUICtrlCreateLabel("Ingredients Needed", 224, 88, 97, 17) $List2 = GUICtrlCreateList("", 224, 104, 121, 201) $Label5 = GUICtrlCreateLabel("Appitezer", 360, 24, 48, 17) $Input[3] = GUICtrlCreateInput("", 360, 40, 137, 21) $Label6 = GUICtrlCreateLabel("Main Course", 360, 64, 63, 17) $Input[4] = GUICtrlCreateInput("", 360, 80, 137, 21) $Input[5] = GUICtrlCreateInput("", 360, 120, 137, 21) $Label7 = GUICtrlCreateLabel("Meal Side #1", 360, 104, 67, 17) $Label8 = GUICtrlCreateLabel("Meal Side #2", 360, 144, 67, 17) $Input[6] = GUICtrlCreateInput("", 360, 160, 137, 21) $Label9 = GUICtrlCreateLabel("Meal Side #3", 360, 184, 67, 17) $Input[7] = GUICtrlCreateInput("", 360, 200, 137, 21) $Label10 = GUICtrlCreateLabel("Main Beverage", 360, 224, 76, 17) $Input[8] = GUICtrlCreateInput("", 360, 240, 137, 21) $Label11 = GUICtrlCreateLabel("Main Desert", 360, 264, 61, 17) $Input[9] = GUICtrlCreateInput("", 360, 280, 137, 21) $Label12 = GUICtrlCreateLabel("Secondary Items", 512, 0, 83, 17) $Label13 = GUICtrlCreateLabel("Beverage", 512, 104, 50, 17) $Input[10] = GUICtrlCreateInput("", 512, 40, 89, 21) $Label14 = GUICtrlCreateLabel("Appitezer", 512, 24, 48, 17) $Input[11] = GUICtrlCreateInput("", 512, 80, 89, 21) $Label15 = GUICtrlCreateLabel("Desert", 512, 144, 35, 17) $Input[12] = GUICtrlCreateInput("", 512, 120, 89, 21) $Label16 = GUICtrlCreateLabel("Course", 512, 64, 37, 17) $Input[13] = GUICtrlCreateInput("", 512, 160, 89, 21) $Edit1 = GUICtrlCreateEdit("", 512, 192, 89, 105, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN)) GUICtrlSetData(-1, "Meal Notes") GUICtrlSetState($List1, $GUI_DISABLE) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Date1 $IniSectionInfo=IniReadSection($INI, GUICtrlRead($Date1)) If Not @error Then GUICtrlSetState($List1, $GUI_ENABLE) For $i=1 To $IniSectionInfo[0][0] _GUICtrlListBox_AddString($List1, $IniSectionInfo[$i][0]) Next For $a=1 To $IniSectionInfo[0][0] $Info=StringSplit($IniSectionInfo[$i][1], "|") For $b=1 To $Info[0] GUICtrlSetData($Input[$i], $Info[$i]) Next Next EndIf EndSwitch WEnd
Paulie Posted April 5, 2008 Posted April 5, 2008 Forgot to define the variable as an array add this to the top Dim $Input[14];increase if you want more controls
Swift Posted April 5, 2008 Author Posted April 5, 2008 Lmao! Thanks dude, I thought about declaring it, but I didn't think it mattered! But thanks Paulie!
Swift Posted April 5, 2008 Author Posted April 5, 2008 Hmm, Hey Paulie, have any idea's why this isnt working? . I feel braindead. expandcollapse popup#include <GUIConstants.au3> #include <GUIListBox.au3> Dim $Input[40] Global $INI=@ScriptDir&"\ini.ini" #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Swift's AutoIt Meal Planner", 609, 308) $Date1 = GUICtrlCreateDate("2008/04/04 20:48:41", 0, 0, 210, 21) $List1 = GUICtrlCreateList("", 0, 24, 209, 253) $Button1 = GUICtrlCreateButton("New Meal", 0, 280, 73, 25, 0) $Button2 = GUICtrlCreateButton("Delete Meal", 80, 280, 75, 25, 0) $Button3 = GUICtrlCreateButton("Edit", 160, 280, 51, 25, 0) $Label1 = GUICtrlCreateLabel("Meal Planner Information", 360, 0, 137, 17) $Input[1] = GUICtrlCreateInput("", 224, 24, 121, 21) $Label2 = GUICtrlCreateLabel("Meal Name", 224, 8, 58, 17) $Input[2] = GUICtrlCreateInput("", 224, 64, 121, 21) $Label3 = GUICtrlCreateLabel("Meal Time", 224, 48, 53, 17) $Label4 = GUICtrlCreateLabel("Ingredients Needed", 224, 88, 97, 17) $List2 = GUICtrlCreateList("", 224, 104, 121, 201) $Label5 = GUICtrlCreateLabel("Appitezer", 360, 24, 48, 17) $Input[3] = GUICtrlCreateInput("", 360, 40, 137, 21) $Label6 = GUICtrlCreateLabel("Main Course", 360, 64, 63, 17) $Input[4] = GUICtrlCreateInput("", 360, 80, 137, 21) $Input[5] = GUICtrlCreateInput("", 360, 120, 137, 21) $Label7 = GUICtrlCreateLabel("Meal Side #1", 360, 104, 67, 17) $Label8 = GUICtrlCreateLabel("Meal Side #2", 360, 144, 67, 17) $Input[6] = GUICtrlCreateInput("", 360, 160, 137, 21) $Label9 = GUICtrlCreateLabel("Meal Side #3", 360, 184, 67, 17) $Input[7] = GUICtrlCreateInput("", 360, 200, 137, 21) $Label10 = GUICtrlCreateLabel("Main Beverage", 360, 224, 76, 17) $Input[8] = GUICtrlCreateInput("", 360, 240, 137, 21) $Label11 = GUICtrlCreateLabel("Main Desert", 360, 264, 61, 17) $Input[9] = GUICtrlCreateInput("", 360, 280, 137, 21) $Label12 = GUICtrlCreateLabel("Secondary Items", 512, 0, 83, 17) $Label13 = GUICtrlCreateLabel("Beverage", 512, 104, 50, 17) $Input[10] = GUICtrlCreateInput("", 512, 40, 89, 21) $Label14 = GUICtrlCreateLabel("Appitezer", 512, 24, 48, 17) $Input[11] = GUICtrlCreateInput("", 512, 80, 89, 21) $Label15 = GUICtrlCreateLabel("Desert", 512, 144, 35, 17) $Input[12] = GUICtrlCreateInput("", 512, 120, 89, 21) $Label16 = GUICtrlCreateLabel("Course", 512, 64, 37, 17) $Input[13] = GUICtrlCreateInput("", 512, 160, 89, 21) $Edit1 = GUICtrlCreateEdit("", 512, 192, 89, 105, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN)) GUICtrlSetData(-1, "Meal Notes") GUICtrlSetState($List1, $GUI_DISABLE) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Date1 $IniSectionInfo=IniReadSection($INI, GUICtrlRead($Date1)) If Not @error Then GUICtrlSetState($List1, $GUI_ENABLE) For $i=1 To $IniSectionInfo[0][0] _GUICtrlListBox_AddString($List1, $IniSectionInfo[$i][0]) Next For $a=1 To $IniSectionInfo[0][0] $Info=StringSplit($IniSectionInfo[$a][1], "|") For $b=1 To $Info[0] GUICtrlSetData($Input[$i], $Info[$i]) Next Next EndIf EndSwitch WEnd A random Ini, name it ini.ini [Friday, April 04, 2008] Breakfast=Breakfast|10:00|apptiz|main|side1|side2|side3|bev|deser just choose the friday april 04, on the calendar. It should set all the data for that day, but it only sets the time? It's probably something obvious. But...
Paulie Posted April 5, 2008 Posted April 5, 2008 (edited) lol you used the wrong variable in your loop try this: expandcollapse popup#include <GUIConstants.au3> #include <GUIListBox.au3> Dim $Input[40] Global $INI=@ScriptDir&"\ini.ini" #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Swift's AutoIt Meal Planner", 609, 308) $Date1 = GUICtrlCreateDate("2008/04/04 20:48:41", 0, 0, 210, 21) $List1 = _GUICtrlListBox_Create($Form1,"", 0, 24, 209, 253) $Button1 = GUICtrlCreateButton("New Meal", 0, 280, 73, 25, 0) $Button2 = GUICtrlCreateButton("Delete Meal", 80, 280, 75, 25, 0) $Button3 = GUICtrlCreateButton("Edit", 160, 280, 51, 25, 0) $Label1 = GUICtrlCreateLabel("Meal Planner Information", 360, 0, 137, 17) $Input[1] = GUICtrlCreateInput("", 224, 24, 121, 21) $Label2 = GUICtrlCreateLabel("Meal Name", 224, 8, 58, 17) $Input[2] = GUICtrlCreateInput("", 224, 64, 121, 21) $Label3 = GUICtrlCreateLabel("Meal Time", 224, 48, 53, 17) $Label4 = GUICtrlCreateLabel("Ingredients Needed", 224, 88, 97, 17) $List2 = GUICtrlCreateList("", 224, 104, 121, 201) $Label5 = GUICtrlCreateLabel("Appitezer", 360, 24, 48, 17) $Input[3] = GUICtrlCreateInput("", 360, 40, 137, 21) $Label6 = GUICtrlCreateLabel("Main Course", 360, 64, 63, 17) $Input[4] = GUICtrlCreateInput("", 360, 80, 137, 21) $Input[5] = GUICtrlCreateInput("", 360, 120, 137, 21) $Label7 = GUICtrlCreateLabel("Meal Side #1", 360, 104, 67, 17) $Label8 = GUICtrlCreateLabel("Meal Side #2", 360, 144, 67, 17) $Input[6] = GUICtrlCreateInput("", 360, 160, 137, 21) $Label9 = GUICtrlCreateLabel("Meal Side #3", 360, 184, 67, 17) $Input[7] = GUICtrlCreateInput("", 360, 200, 137, 21) $Label10 = GUICtrlCreateLabel("Main Beverage", 360, 224, 76, 17) $Input[8] = GUICtrlCreateInput("", 360, 240, 137, 21) $Label11 = GUICtrlCreateLabel("Main Desert", 360, 264, 61, 17) $Input[9] = GUICtrlCreateInput("", 360, 280, 137, 21) $Label12 = GUICtrlCreateLabel("Secondary Items", 512, 0, 83, 17) $Label13 = GUICtrlCreateLabel("Beverage", 512, 104, 50, 17) $Input[10] = GUICtrlCreateInput("", 512, 40, 89, 21) $Label14 = GUICtrlCreateLabel("Appitezer", 512, 24, 48, 17) $Input[11] = GUICtrlCreateInput("", 512, 80, 89, 21) $Label15 = GUICtrlCreateLabel("Desert", 512, 144, 35, 17) $Input[12] = GUICtrlCreateInput("", 512, 120, 89, 21) $Label16 = GUICtrlCreateLabel("Course", 512, 64, 37, 17) $Input[13] = GUICtrlCreateInput("", 512, 160, 89, 21) $Edit1 = GUICtrlCreateEdit("", 512, 192, 89, 105, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN)) GUICtrlSetData(-1, "Meal Notes") GUICtrlSetState($List1, $GUI_DISABLE) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Date1 $IniSectionInfo=IniReadSection($INI, GUICtrlRead($Date1)) If Not @error Then GUICtrlSetState($List1, $GUI_ENABLE) For $i=1 To $IniSectionInfo[0][0] _GUICtrlListBox_AddString(ControlGetHandle($Form1,"",$List1), $IniSectionInfo[$i][0]) Next For $a=1 To $IniSectionInfo[0][0] $Info=StringSplit($IniSectionInfo[$a][1], "|") For $b=1 To $Info[0] GUICtrlSetData($Input[$b], $Info[$b]) Next Next EndIf EndSwitch WEnd EDIT: removed debugging msgboxes Edited April 5, 2008 by Paulie
Swift Posted April 5, 2008 Author Posted April 5, 2008 Haha, thanks Paulie, I knew I missed something! Now, to get more stuff! Because now, I need to check if Breakfast/dinner is selected, and then populate it among that.
Swift Posted April 5, 2008 Author Posted April 5, 2008 Double-Post Again. Sorry. New Question! I'm not sure how to do this, when I choose a date, do not populate the inputs, only the ListBox, but then, when the listbox is clicked, get the clicked one, and populate the inputs. . Just tell me the functions, and im done! Thanks Everyone!
Moderators SmOke_N Posted April 5, 2008 Moderators Posted April 5, 2008 GUICtrlRead ... I see 1400 posts haven't gone to waste... 6 minutes between posts and posting another question you obviously put no effort into researching. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Swift Posted April 5, 2008 Author Posted April 5, 2008 GUICtrlRead ... I see 1400 posts haven't gone to waste... 6 minutes between posts and posting another question you obviously put no effort into researching.Well...Sorry Smoke_N, I thought I needed a _GUICtrlListView_* Function.
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