Jump to content

Recommended Posts

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 :/

Link to post
Share on other sites

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)

NEWHeader1.png

Link to post
Share on other sites

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 by possmkngdm
Link to post
Share on other sites

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

<{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)

NEWHeader1.png

Link to post
Share on other sites

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" button

then the "attach" button ( after it uploads)

ok?

8)

NEWHeader1.png

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...