AlmarM Posted April 22, 2009 Posted April 22, 2009 (edited) Hi,If I used _FileListToArray to get some file names...Lets say we have like 5 files in "C:\Test"Example$Path = "C:\Test\" $File = _FileListToArray($File, "*", 1) MsgBox(0, "", $File[1])So $File[1] will be the first file.So how can I get the name into a msgbox?AlmarM Edited April 22, 2009 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.
ShawnW Posted April 22, 2009 Posted April 22, 2009 $File = _FileListToArray($Path, "*", 1) not $File = _FileListToArray($File, "*", 1) other than that I don't know what problem you are having because that should already display the name in a message box
Valuater Posted April 22, 2009 Posted April 22, 2009 Alarm = 888 posts Shawn = 2 posts .... Hmmm, wonder who reads and uses the help file?? 8)
ShawnW Posted April 23, 2009 Posted April 23, 2009 Alarm = 888 postsShawn = 2 posts.... Hmmm, wonder who reads and uses the help file??8)was that comment against me and my lack of post?cause his code = failmy code = 4 da win
Valuater Posted April 23, 2009 Posted April 23, 2009 was that comment against me and my lack of post?cause his code = failmy code = 4 da winNo Shawn, not at all.His code = fail when he has 888 postsyour code = 4 da win with only having two posts8)
John117 Posted April 23, 2009 Posted April 23, 2009 (edited) hahaha 4 da win :-) I think he just made a goof and mixed up the $Variables . . . Easy enough todo . . . for me anyway ;-) Edited April 23, 2009 by Hatcheda
AlmarM Posted April 23, 2009 Author Posted April 23, 2009 (edited) Ok, this works. #include <Array.au3> #include <File.au3> DirCreate("C:\AlmarM\") $Path = "C:\AlmarM\" FileWrite($Path & "test1.txt", "test1") FileWrite($Path & "test2.txt", "test2") FileWrite($Path & "test3.txt", "test3") FileWrite($Path & "test4.txt", "test4") $File = _FileListToArray($Path) _ArrayDisplay($File) MsgBox(0, "", $File[2]) Func OnAutoItExit() FileDelete($Path & "test1.txt") FileDelete($Path & "test2.txt") FileDelete($Path & "test3.txt") FileDelete($Path & "test4.txt") DirRemove($Path) EndFunc I think im just stupid and I missing something AlmarM EDIT: Typo Edited April 23, 2009 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.
KaFu Posted April 23, 2009 Posted April 23, 2009 (edited) Because $File[2] is still an array.#include <Array.au3> #include <File.au3> Dim $SubItem[9], $File[9] ;$Path = "C:\Documents and Settings\Gortstraat_41\Bureaublad\GM handbook v62\GM Handbook v62\" $Path = @ScriptDir $SubItem[0] = $Path & "Character\" $SubItem[1] = $Path & "Character\Equips" $SubItem[2] = $Path $SubItem[3] = $Path & "Items" $SubItem[4] = $Path & "Maps, portal" $SubItem[5] = $Path & "Misc" $SubItem[6] = $Path & "NPC" $SubItem[7] = $Path & "Pet" $SubItem[8] = $Path & "Monsters" For $i = 0 To 8 $File[$i] = _FileListToArray($SubItem[$i], "*", 1) Next _ArrayDisplay($File[2])Edit: Trying to access the values in the array with something likemsgbox(0,"",$File[2][0])resulted in error. Reading the help-file I found:"It was said that an Array contains only one datatype of the same type. But technically speaking, a Variant in AutoIt can contain anything from a number to a boolean value. So an AutoIt-Array could also contain different types, even other Arrays. This has not been strictly forbidden in AutoIt. However, it is NOT ADVISABLE to mix different datatypes in an Array. Especially the use of an Array inside another Array will severely affect the execution speed of your script."So I suggest you better switch to use a single array... #include <Array.au3> #include <File.au3> Dim $SubItem[9],$Filelist_Total[1] ;$Path = "C:\Documents and Settings\Gortstraat_41\Bureaublad\GM handbook v62\GM Handbook v62\" $Path = @ScriptDir & "\" $SubItem[0] = $Path & "PHP\" $SubItem[1] = $Path & "Character\Equips" $SubItem[2] = $Path $SubItem[3] = $Path & "Items" $SubItem[4] = $Path & "Maps, portal" $SubItem[5] = $Path & "Misc" $SubItem[6] = $Path & "NPC" $SubItem[7] = $Path & "Pet" $SubItem[8] = $Path & "Monsters" For $i = 0 To 8 $Filelist_Single = _FileListToArray($SubItem[$i], "*", 1) if IsArray($Filelist_Single) and UBound($Filelist_Single) > 1 then ReDim $Filelist_Total[UBound($Filelist_Total)+UBound($Filelist_Single)-1] $Filelist_Total[0] += $Filelist_Single[0] for $n = 1 to UBound($Filelist_Single)-1 $Filelist_Total[UBound($Filelist_Total)-UBound($Filelist_Single)+$n] = $Filelist_Single[$n] Next endif Next _ArrayDisplay($Filelist_Total)And I'll bet there are solutions with a better performance out there ... Edited April 23, 2009 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
AlmarM Posted April 23, 2009 Author Posted April 23, 2009 Ye, thats the problem... I want all the paths including the files... $SubItem[0] & $File[0] Should return C:\Documents and Settings\Gortstraat_41\Bureaublad\GM handbook v62\GM Handbook v62\xxxx.txt AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.
rudi Posted April 23, 2009 Posted April 23, 2009 Hi.Use this UDF: "_FileListToArray3.au3".#include "c:\install\FileListToArray3\FileListToArray3.au3" #include <array.au3> $Path="C:\Windows\system32" $System32=_FileListToArray3($Path,"*",1, 1, 1) ; *=filter; 1=files only; 1=recurse; 1=return full path and filename _ArrayDisplay($system32)Regards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE!
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