Sign in to follow this  
Followers 0
Skrip

File Find?

17 posts in this topic

How can I find all the files in a selected folder, then have them input into an edit (or list) box? I've looked in the helpfile and found _FileListToArray, but I can't get it to input into the editbox.

#Include <File.au3>
#Include <Array.au3>
$ddir = _FileListToArray("C:\")
Func FList()
    $file = $ddir
    For $i = 1 To $file[0][0]
        GUICtrlSetData($List1, $file[$i][0], 1)
    Next
EndFunc;==>FList

(GUI not included. It seems un-nessary to post it. I will if it's needed.)

What exactly am I doing wrong?


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites



_FileListToArray returns a one dimensional array...

change

$file[0][0]

to

$file[0]

and change

$file[$i][0]

to

$file[$i]


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

How can I find all the files in a selected folder, then have them input into an edit (or list) box? I've looked in the helpfile and found _FileListToArray, but I can't get it to input into the editbox.

(Snip)

(GUI not included. It seems un-nessary to post it. I will if it's needed.)

What exactly am I doing wrong?

Something like this work?

#Include <File.au3>
#Include <Array.au3>
$ddir = _FileListToArray("C:\")
$ListInfo = ""
Func FList()
    $file = $ddir
    For $i = 1 To $file[0]
        $Listinfo = $ListInfo&"|"&$file[$i]
    Next
    GUICtrlSetData($List1, $ListInfo, 1)
EndFunc;==>FList

EDIT: what you were doing before would only end up setting the last file to the list, this works as long as you don't have way too many files to exceed the maximum string length

Edited by Paulie

Share this post


Link to post
Share on other sites

What exactly is the max string legnth?


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

as you would have found, had you looked in the help file :whistle:


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

That is, of course, where I got the answer.

I'm surprised people don't look there more often. It's one of the best help files ever.

(edit bolded :whistle: )

Edited by xcal

Share this post


Link to post
Share on other sites

That is, of course, where I got the answer.

I'm surprised people look there more often. It's one of the best help files ever.

Yes, it makes no sense why people waste the time of the people willing to give support by asking questions that could be easily found just by simply opening the help file :whistle:

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

Yes, it makes no sense why people waste the time of the people willing to give support by asking questions that could be easily found just by simply opening the help file :whistle:

The answer is simple, they don't know that there is a helpfile.

I think that the helpfile should open immediately after the autoit program is downloaded, and it should not be able to be closed for like 30 seconds or something

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt('MustDeclareVars', 1)

Dim $a_check[10], $msg, $ret, $s_attr
Dim $input, $group, $a_attr, $listbox, $button, $btn_exit

GUICreate("ListBox Add Item Demo", 400, 250, -1, -1)
GUICtrlCreateLabel("Enter files to find", 25, 15)
$input = GUICtrlCreateInput("c:\*.*", 125, 10, 180, 25)
$group = GUICtrlCreateGroup("Atrributes", 10, 40, -1, 200)
$a_attr = StringSplit("A,D,H,RO,RW,S,E,Drives,NB", ",")
$a_check[0] = 9
$a_check[1] = GUICtrlCreateCheckbox("Archive", 15, 55, 170, 20)
GUICtrlSetState($a_check[1], $GUI_CHECKED)
$a_check[2] = GUICtrlCreateCheckbox("Directory", 15, 75, 170, 20)
$a_check[3] = GUICtrlCreateCheckbox("Hidden", 15, 95, 170, 20)
GUICtrlSetState($a_check[3], $GUI_CHECKED)
$a_check[4] = GUICtrlCreateCheckbox("Read-Only", 15, 115, 170, 20)
GUICtrlSetState($a_check[4], $GUI_CHECKED)
$a_check[5] = GUICtrlCreateCheckbox("Read-Write", 15, 135, 95, 20)
GUICtrlSetState($a_check[5], $GUI_CHECKED)
$a_check[6] = GUICtrlCreateCheckbox("System", 15, 155, 170, 20)
GUICtrlSetState($a_check[6], $GUI_CHECKED)
$a_check[7] = GUICtrlCreateCheckbox("Exclusive", 15, 175, 170, 20)
GUICtrlSetState($a_check[7], $GUI_CHECKED)
$a_check[8] = GUICtrlCreateCheckbox("Drives", 15, 195, 170, 20)
$a_check[9] = GUICtrlCreateCheckbox("No Brackets (Drives Only)", 15, 215, 170, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1)  ;close group

$listbox = GUICtrlCreateList("", 240, 40, 120, 120)
$button = GUICtrlCreateButton("Get Names", 240, 160, 120, 40)
$btn_exit = GUICtrlCreateButton("Exit", 240, 205, 120, 40)

GUISetState()
$ret = _GUICtrlListAddDir ($listbox, "A,H,RO,RW,S,E", GUICtrlRead($input))

While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_CLOSE Or $msg = $btn_exit
         ExitLoop
      Case $msg = $button
         $s_attr = ""
         For $i = 1 To $a_check[0]
            If (BitAND(GUICtrlRead($a_check[$i]), $GUI_CHECKED)) Then
               If (StringLen($s_attr) > 0) Then
                  $s_attr &= "," & $a_attr[$i]
               Else
                  $s_attr = $a_attr[$i]
               EndIf
            EndIf
         Next
         _GUICtrlListClear ($listbox)
         $ret = _GUICtrlListAddDir ($listbox, $s_attr, GUICtrlRead($input))
         If ($ret < 0) Then
            If ($ret == $LB_ERRATTRIBUTE) Then
               MsgBox(16, "Error", "Invalid Attribute sent to _GUICtrlListAddDir")
            ElseIf ($ret == $LB_ERRSPACE) Then
               MsgBox(16, "Error", "insufficient space to store the new strings from calling _GUICtrlListAddDir")
            ElseIf ($ret == $LB_ERRREQUIRED) Then
               MsgBox(16, "Error", "Argument required for file search in call to _GUICtrlListAddDir")
            ElseIf ($ret == $LB_ERR) Then
               MsgBox(16, "Error", "Unknown error from _GUICtrlListAddDir" & @CRLF & "Possibly no files/folders found")
            EndIf
         EndIf
   EndSelect
WEnd


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

The answer is simple, they don't know that there is a helpfile.

I think that the helpfile should open immediately after the autoit program is downloaded, and it should not be able to be closed for like 30 seconds or something

In responce to you people saying I didn't look in the help file. I did. I didn't know it was a one dimension array. I figured it out in the first reply. You don't have to go on and on about it.


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

In responce to you people saying I didn't look in the help file. I did. I didn't know it was a one dimension array. I figured it out in the first reply. You don't have to go on and on about it.

it states very clearly, the very first remark, it says

"The array returned is one-dimensional"

If you did look in the help file, I can't imagine why you wouldn't know this...It is the first remark, after all...

In the future, it's best to actually read what the help file says, not just glance with your eyes closed or whatever it is you did to miss that...


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

I'm not very good at using arrays. I've made a 2000 line program, without using one array. It has never really been needed for me before. I didn't exactly know what a one-dimensional array was. But after that first post I found that part out.


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

I'm not very good at using arrays. I've made a 2000 line program, without using one array. It has never really been needed for me before. I didn't exactly know what a one-dimensional array was. But after that first post I found that part out.

oh lol, well you could have said that the first time instead of saying "I didn't know it was one-dimensional" :whistle:

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

Good-point. Let's all forget this ever happend.


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

In responce to you people saying I didn't look in the help file. I did. I didn't know it was a one dimension array. I figured it out in the first reply. You don't have to go on and on about it.

I wasn't saying you never looked in the helpfile, someone made a comment saying that they didn't understand why people don't read the helpfile, and I replied saying the reason is that they don't know that the helpfile is so good, because the helps for most programs suck.

Share this post


Link to post
Share on other sites

I wasn't saying you never looked in the helpfile, someone made a comment saying that they didn't understand why people don't read the helpfile, and I replied saying the reason is that they don't know that the helpfile is so good, because the helps for most programs suck.

Good-point. Let's all forget this ever happend.

it doesnt matter, just forget it.


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


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
Sign in to follow this  
Followers 0