develogy Posted February 12, 2014 Share Posted February 12, 2014 I am attempting to build a list from a series of directories under the ScriptPath of standalone system monitor applications that have also been built in AutoItThe goal is to get the list of directories that Start with "Monitor-", then place them in an array, then when refreshing the status ListView, I will also be checking a text file for each one to get its current status, but for now that is just being filled in with "PAUSED".I can get the correct directories, but when I try to loop through it to put in the list view I get this error:J:ProjectsSysMonMonStatus.au3 (39) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:$aItems[$i][0] = $MonitorList[$b][0]$aItems[$i][0] = ^ ERRORAny ideas from all of you AutoIt Wizards? expandcollapse popup;************ Includes ************ #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <File.au3> #include <Array.au3> ;************ Includes ************ AdlibRegister("RefreshMonitorList",500) Global $MonitorListView RefreshMonitorList() GUICreate("Monitor Status Check", 400, 300) $MonitorListView = GUICtrlCreateListView("", 2, 2, 394, 268) GUISetState(@SW_SHOW) ; Add columns _GUICtrlListView_AddColumn($MonitorListView, "Monitor Name", 100) _GUICtrlListView_AddColumn($MonitorListView, "Status", 100) Func GetMonitors() Local $MonitorList = _FileListToArray(@ScriptDir, "Monitor-*", 2) If @error = 1 Then MsgBox(4096, "", "Path was invalid.") Exit EndIf If @error = 4 Then MsgBox(4096, "", "No Monitors were found.") Exit EndIf ; Display the results returned by _FileListToArray. ;_ArrayDisplay($MonitorList, "$MonitorList") Return $MonitorList EndFunc Func RefreshMonitorList() $MonitorList = GetMonitors() _GUICtrlListView_DeleteAllItems($MonitorListView) Local $aItems[5000][2] For $i = 0 To UBound($MonitorList) - 1 $b = $i + 1 $aItems[$i][0] = $MonitorList[$b][0] $aItems[$i][1] = "PAUSED" Next _GUICtrlListView_AddArray($MonitorListView, $aItems) EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 12, 2014 Moderators Share Posted February 12, 2014 develogy,_FileListToArray only returns a 1D array - you are using 2D syntax to access it. Plus you are going too far into the array - see below. This should work:Local $aItems[UBound($MonitorList) - 1][2] ; Why 5000 when you know how big it needs to be? For $i = 0 To UBound($MonitorList) - 2 ; Otherwise $i + 1 will fail as it is outside the bounds $aItems[$i][0] = $MonitorList[$i + 1] ; Use 1D syntax here $aItems[$i][1] = "PAUSED" NextAll clear? 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...
develogy Posted February 12, 2014 Author Share Posted February 12, 2014 Thanks Melba,You were spot on. 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