LongBowNZ Posted September 26, 2007 Share Posted September 26, 2007 $ModList=_FileListToArray($BF_ModDir, Default, 2) For $i = 1 To $ModList[0] Step 1 GUICtrlCreateListViewItem($ModList[$i], $ModListView) Next Gives me the error ==> Subscript used with non-Array variable.: For $i = 1 To $ModList[0] Step 1 For $i = 1 To $ModList^ ERROR Link to comment Share on other sites More sharing options...
maqleod Posted September 26, 2007 Share Posted September 26, 2007 $ModList=_FileListToArray($BF_ModDir, Default, 2) For $i = 1 To $ModList[0] Step 1 GUICtrlCreateListViewItem($ModList[$i], $ModListView) Next Gives me the error You should test for these as it appears your array is not being created: @Error: 1 = Path not found or invalid 2 = Invalid $sFilter 3 = Invalid $iFlag 4 = No File(s) Found [u]You can download my projects at:[/u] Pulsar Software Link to comment Share on other sites More sharing options...
LongBowNZ Posted September 26, 2007 Author Share Posted September 26, 2007 You should test for these as it appears your array is not being created: @Error: 1 = Path not found or invalid 2 = Invalid $sFilter 3 = Invalid $iFlag 4 = No File(s) Found$ModList=_FileListToArray($BF_ModDir, Default, 2) If @Error=1 Then MsgBox(0, "", "Path not found or invalid.") Exit EndIf If @Error=2 Then MsgBox(0, "", "Invalid $sFilter.") Exit EndIf If @Error=3 Then MsgBox(0, "", "Invalid $iFlag.") Exit EndIf If @Error=4 Then MsgBox(0, "", "No File(s) Found.") Exit EndIf For $i = 1 To $ModList[0] Step 1 GUICtrlCreateListViewItem($ModList[$i], $ModListView) Next "No File(s) Found" is what it comes up with even though in the folder "$BF_ModDir" there is 13 Folders and I thought setting the last param in _FileListToArray to 2 makes it return folders? Link to comment Share on other sites More sharing options...
Nahuel Posted September 26, 2007 Share Posted September 26, 2007 (edited) This should work: $ModList=_FileListToArray($BF_ModDir, "*.", 2) If @Error=1 Then MsgBox(0, "", "Path not found or invalid.") Exit EndIf If @Error=2 Then MsgBox(0, "", "Invalid $sFilter.") Exit EndIf If @Error=3 Then MsgBox(0, "", "Invalid $iFlag.") Exit EndIf If @Error=4 Then MsgBox(0, "", "No File(s) Found.") Exit EndIf For $i = 1 To $ModList[0] Step 1 GUICtrlCreateListViewItem($ModList[$i], $ModListView) Next I don't know if it'll be of any help, but you could check out 'Rename all files in a directory' in my signature. It uses that function. Edited September 26, 2007 by Nahuel Link to comment Share on other sites More sharing options...
Nahuel Posted September 26, 2007 Share Posted September 26, 2007 Here: expandcollapse popup#include <file.au3> #include <GUIConstants.au3> GUICreate("Form1", 285, 308, 269, 113) $ModListView=GUICtrlCreateListView("Test ",15,15) GUISetState(@SW_SHOW) $BF_ModDir=@ProgramFilesDir $ModList=_FileListToArray($BF_ModDir, "*.", 2) If @Error=1 Then MsgBox(0, "", "Path not found or invalid.") Exit EndIf If @Error=2 Then MsgBox(0, "", "Invalid $sFilter.") Exit EndIf If @Error=3 Then MsgBox(0, "", "Invalid $iFlag.") Exit EndIf If @Error=4 Then MsgBox(0, "", "No File(s) Found.") Exit EndIf For $i = 1 To $ModList[0] Step 1 GUICtrlCreateListViewItem($ModList[$i], $ModListView) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
Stalker0 Posted September 26, 2007 Share Posted September 26, 2007 The only thing I have to add is make sure you are including all of the files you need, most of my array errors come from that simple thing. Link to comment Share on other sites More sharing options...
LongBowNZ Posted September 26, 2007 Author Share Posted September 26, 2007 This should work: $ModList=_FileListToArray($BF_ModDir, "*.", 2)Filter param was the problem. In the help file it says the Default is "*." but putting Default doesn't work, don't know if thats a bug or not? Anyway thanks Nahuel 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