possmkngdm Posted September 2, 2005 Posted September 2, 2005 Intention: search files in a directory and add to array ; search for users FileChangeDir($userDir) $search = FileFindFirstFile("*.ini") If $search = -1 Then MsgBox(0, "Error", "No user files found") Exit EndIf ; get list of user ini files Dim $userList[1] $i = 0 While 1 ReDim $userList[$i + 1] $user = FileFindNextFile($search) If @error Then ExitLoop $userList[$i] = $user WEnd $userList ends up with just the last found filename :/
Valuater Posted September 2, 2005 Posted September 2, 2005 maybe more like this Dim $userList, $i = 0, $userDir ; search for users FileChangeDir($userDir) $search = FileFindFirstFile("*.ini") If $search = -1 Then MsgBox(0, "Error", "No user files found") Exit EndIf ; get list of user ini files for $i = 1 to 1000 $user = FileFindNextFile($search) If @error Then ExitLoop $userList[$i] = $user MsgBox(0,"user", $userList[$i]) Next 8)
possmkngdm Posted September 2, 2005 Author Posted September 2, 2005 (edited) hmm...keep getting $userList[$i] = $user $userList^ ERROR Error: Expected a "=" operator in assignment statement. (got same error trying to get my code with the while loop to work as well) Edited September 2, 2005 by possmkngdm
Valuater Posted September 2, 2005 Posted September 2, 2005 try this...replace this Dim $userList, $i = 0, $userDir with this Dim $userList[100], $i = 0, $userDir i can't actually test this... ok 8)
possmkngdm Posted September 2, 2005 Author Posted September 2, 2005 (edited) ah, thanks, thought I already tried that, but tried it again and it worked only issue is that the array doesn't actually grow (which I was aiming for), the resulting array gets padded to fill the initialized size if there are less elements Edited September 2, 2005 by possmkngdm
Valuater Posted September 2, 2005 Posted September 2, 2005 ah, thanks, thought I already tried that, but tried it again and it workedonly issue is that the array doesn't actually grow (which I was aiming for), the resulting array gets padded to fill the initialized size if there are less elements<{POST_SNAPBACK}>not sure i understand... but maybe this????Dim $userList[100], $i = 0, $userDir, $usertotal ; search for users FileChangeDir($userDir) $search = FileFindFirstFile("*.ini") If $search = -1 Then MsgBox(0, "Error", "No user files found") Exit EndIf ; get list of user ini files for $i = 1 to 1000 $user = FileFindNextFile($search) If @error Then ExitLoop $userList[$i] = $user $usertotal = $usertotal & "num " & $i & " " & $userList[$i] & @CRLF MsgBox(0,"user", $userList[$i]) Next MsgBox(0,"user", $usertotal)8)
possmkngdm Posted September 2, 2005 Author Posted September 2, 2005 ah, that's the trick, thanks a lot!!!
Valuater Posted September 2, 2005 Posted September 2, 2005 please post a pic of your last message box.... ok 8)
possmkngdm Posted September 3, 2005 Author Posted September 3, 2005 not exactly sure how you would post a pic here, but if you want, I can post it to my website...let me know
Valuater Posted September 3, 2005 Posted September 3, 2005 not exactly sure how you would post a pic here, but if you want, I can post it to my website...let me know<{POST_SNAPBACK}>when you open the screen to create a post ( where i am typing right now)at the bottom there is a "Browse" buttonthen the "attach" button ( after it uploads)ok?8)
Valuater Posted September 3, 2005 Posted September 3, 2005 here you, thanks again!<{POST_SNAPBACK}>Cool... Cool... Cool...Just like I imagined while I was writting in the dark ( not able to test it)Enjoy!8)
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