damian666 Posted August 8, 2009 Share Posted August 8, 2009 i want to let a user select multiple files, and then add it to a listview. so, i use stringsplit to get a array, but what then??? see my code of what i tried XD $var = FileOpenDialog(" Wim Image Mounter", " ", "Language Packs (*.Cab)", 1 + 2 + 4, "lp.cab") $Pack = StringSplit($var, "|") If Not @error Then ;Create listview items For $x = 0 To $Pack[0] $ListView1_[$x] = GUICtrlCreateListViewItem($Pack[+1], $ListView1) Next EndIf now, i was suprised it didnt error ^^, but it also doesnt do what i want, fill my listview with the filenames it repeats the first filename over and over, till the max number of files is reached... any help is appriciated >_< Damian666 and proud of it!!! Link to comment Share on other sites More sharing options...
Hawkwing Posted August 8, 2009 Share Posted August 8, 2009 On your fourth line of code try replacing $Pack[+1] with $Pack[$x]. The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again. Link to comment Share on other sites More sharing options...
WolfWorld Posted August 8, 2009 Share Posted August 8, 2009 $var = FileOpenDialog(" Wim Image Mounter", " ", "Language Packs (*.Cab)", 1 + 2 + 4, "lp.cab") If Not @error Then GUICtrlCreateListViewItem($var, $ListView1) EndIf Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
WolfWorld Posted August 8, 2009 Share Posted August 8, 2009 On your fourth line of code try replacing $Pack[+1] with $Pack[$x]. You don't even need to do that. Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
damian666 Posted August 8, 2009 Author Share Posted August 8, 2009 (edited) damn your fast XD ok, that does work, but now i have the problem of having to seperate the first 2 array values, which ofcourse gimme the total number, and filepath in this context. how would i set $x to begin at array entry 3? and while were at it, when i have a listview with 3 colums, would it then be: $var = FileOpenDialog(" Wim Image Mounter", " ", "Language Packs (*.Cab)", 1 + 2 + 4, "lp.cab") $Pack = StringSplit($var, "|") If Not @error Then ;Create listview items For $x = 0 To $Pack[0] $ListView1_[$x] = GUICtrlCreateListViewItem($Pack[$x] & "|" & $Pack[$x] & "|" & $Pack[$x], $ListView1) Next EndIf ??? thanx for helping me out mate ^^ both of you >_< Damian666 Edited August 8, 2009 by damian666 and proud of it!!! Link to comment Share on other sites More sharing options...
Hawkwing Posted August 8, 2009 Share Posted August 8, 2009 Yes, the that is how you would create a listview with columns. To make it begin at array entry 3, well, $x starts at 0, so do $Pack[$x + 3]. The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again. Link to comment Share on other sites More sharing options...
damian666 Posted August 8, 2009 Author Share Posted August 8, 2009 (edited) hmm... but that seems to error mate... ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: and it highlights the $Pack with the +3 also, when i select only 1 file, it doesnt show anything at all :S sorry i ask so much, i have been using AI for 2 years now, but i never had to use arrays this much XD Edit: the part of starting it on third entry i figured, it should be $x = 2 to $pack[0] but it wont show anything on selecting only 1 file... Damian666 Edited August 8, 2009 by damian666 and proud of it!!! Link to comment Share on other sites More sharing options...
Hawkwing Posted August 8, 2009 Share Posted August 8, 2009 (edited) Oh, duh, I should have realized that the dimension would have been exceeded. Stupid mistake. I guess I misunderstood your question. I thought that you wanted to populate the listview starting with the 3rd file selected. Woops. This should work. $var = FileOpenDialog(" Wim Image Mounter", " ", "Language Packs (*.Cab)", 1 + 2 + 4, "lp.cab") $Pack = StringSplit($var, "|") Dim $Packstartat3[$Pack[0] + 3] For $i = 1 To $Pack[0] $Packstartat3[$i + 2] = $Pack[$i] Next If Not @error Then ;Create listview item For $x = 0 To $Pack[0] $ListView1_[$x] = GUICtrlCreateListViewItem($Packstartat3[$x], $ListView1) Next EndIf You won't, of course, have the first value of the new array being the dimensions, so you will have to use ubound if you need the dimensions. Edited August 8, 2009 by Hawkwing The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again. Link to comment Share on other sites More sharing options...
WolfWorld Posted August 8, 2009 Share Posted August 8, 2009 This is faster! $var = FileOpenDialog(" Wim Image Mounter", " ", "Language Packs (*.Cab)", 1 + 2 + 4, "lp.cab") $Pack = StringSplit($var, "|") If Not @error Then ;Create listview item For $x = 0 To $Pack[0] - 3 $ListView1_[$x] = GUICtrlCreateListViewItem($Pack[$x + 3], $ListView1) Next EndIf Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
damian666 Posted August 8, 2009 Author Share Posted August 8, 2009 hmm... well... i rather not use ubound, that gets even harder for me then XD i have this so far: $var = FileOpenDialog(" Wim Image Mounter", " ", "Language Packs (*.Cab)", 1 + 2 + 4, "lp.cab") $Pack = StringSplit($var, "|") If Not @error Then ;Create listview items For $x = 2 To $Pack[0] $ListView1_[$x] = GUICtrlCreateListViewItem($Pack[1] & "\" & $Pack[$x], $ListView1) ConsoleWrite($Pack[1] & "\" & $Pack[$x] & @CRLF) Next $ListView1_[$x] = GUICtrlCreateListViewItem("", $ListView1) EndIf only issue left, is when selecting 1 file, it wont show anything in my listview, multiple work great though ^^ Damian666 and proud of it!!! Link to comment Share on other sites More sharing options...
GEOSoft Posted August 8, 2009 Share Posted August 8, 2009 Better to get the practice with Ubound() $aArray[0] only works for 1 based arrays and many times it's not a 1 based array that's returned. For $i = 1 To Ubound($aArray) -1 or For $i= 0 to Ubound($aArray) -1 Will work no matter what. 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...
damian666 Posted August 8, 2009 Author Share Posted August 8, 2009 yeah... i thought you would say that ^^ but seeying i have it working except that little issue, i can get off the hook for now >_< because i guess using ubound in this context wont solve that problem right? Damian666 and proud of it!!! Link to comment Share on other sites More sharing options...
Hawkwing Posted August 8, 2009 Share Posted August 8, 2009 Do For $x = 1 To... instead of $x = 2. I think you got that from my mistaken assumption that you wanted to leave out the first few files rather that have the array start at 3. The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again. Link to comment Share on other sites More sharing options...
WolfWorld Posted August 8, 2009 Share Posted August 8, 2009 Do For $x = 1 To... instead of $x = 2. I think you got that from my mistaken assumption that you wanted to leave out the first few files rather that have the array start at 3.I thought he want to leave out 4 files $x = 3 remember?Yap, you are not the only one confuse. Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
Hawkwing Posted August 8, 2009 Share Posted August 8, 2009 I think he wanted to start the array at 3 and I thought he meant he wanted to start populating the listview at 3, therefore leaving out some files. Now we're all confused. The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again. Link to comment Share on other sites More sharing options...
damian666 Posted August 8, 2009 Author Share Posted August 8, 2009 its not that i want to populate it at line 3, i want it to start populating it from the beginning, but without the first few array entries, because those will gimme number of files, and filepath. and i just need filenames. as you see in my code, i use the combination of 2, to get filepath, AND filename to form myself a whole filepath. only issue, when selecting 1 file only, it just doesnt show anything on the listview. Damian666 and proud of it!!! Link to comment Share on other sites More sharing options...
Hawkwing Posted August 8, 2009 Share Posted August 8, 2009 If it's working completely except for that, just use an If...Else...Then and check $Pack for "|". If it doesn't have it then just put the one file on the listview, else use the For...Next that you already have working. The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again. Link to comment Share on other sites More sharing options...
damian666 Posted August 8, 2009 Author Share Posted August 8, 2009 oh duh... and here i am looking at some weird stuff to do the same easy thing... xD thanx man, that will conclude our little help session for today, you learned me some stuff, always good ^^ thanx a bunch >_<, all of you. Damian666 and proud of it!!! 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