rbhkamal Posted May 10, 2006 Share Posted May 10, 2006 (edited) in the File.au3 I found under function _FileListToArray() :$hSearch = FileFindFirstFile($sPath & "\" & $sFilter) If $hSearch = -1 Then SetError(0) Return 0 EndIfBut in the beta help:Return Value @Error: 1 = No files\folders found in dir 2 = Path Not Found. 3 = $iFlag was invalid.Shouldn't "SetError(0)" be changed to "SetError(1)"? Edited May 10, 2006 by rbhkamal "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
Developers Jos Posted May 10, 2006 Developers Share Posted May 10, 2006 in the File.au3 I found under function _FileListToArray() : $hSearch = FileFindFirstFile($sPath & "\" & $sFilter) If $hSearch = -1 Then SetError(0) Return 0 EndIf But in the beta help: Return Value @Error: 1 = No files\folders found in dir 2 = Path Not Found. 3 = $iFlag was invalid. Shouldn't "SetError(0)" be changed to "SetError(1)"? Think it sould say: ; @Error=1 Path not found or invalid ; @Error=2 Invalid $sFilter ; @Error=3 Invalid $iFlag SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
rbhkamal Posted May 10, 2006 Author Share Posted May 10, 2006 (edited) Looked again an seems like there is duplicated cases where @error is set to 0 1- No files found @error = 0 2- Success @error = 0 However if you switch number (1) to @error=1 then the return will be 1 then: 1-No files found @error = 1 2-Path not Valid @error = 1 and here you go...... .........Uh Here is the function:expandcollapse popup;=================================================== ; ; Description: lists all files and folders in a specified path (Similar to using Dir with the /B Switch) ; Syntax: _FileListToArray($sPath, $sFilter = "*", $iFlag = 0) ; Parameter(s): $sPath = Path to generate filelist for ; $iFlag = determines weather to return file or folders or both ; $sFilter = The filter to use. Search the Autoit3 manual for the word "WildCards" For details ; $iFlag=0(Default) Return both files and folders ; $iFlag=1 Return files Only ; $iFlag=2 Return Folders Only ; ; Requirement(s): None ; Return Value(s): On Success - Returns an array containing the list of files and folders in the specified path ; On Failure - Returns an empty string "" if no files are found and sets @Error on errors ; @Error=1 Path not found or invalid ; @Error=2 Invalid $sFilter ; @Error=3 Invalid $iFlag ; ; Author(s): SolidSnake <MetalGearX91 at Hotmail dot com> ; Note(s): The array returned is one-dimensional and is made up as follows: ; $array[0] = Number of Files\Folders returned ; $array[1] = 1st File\Folder ; $array[2] = 2nd File\Folder ; $array[3] = 3rd File\Folder ; $array[n] = nth File\Folder ; ; Special Thanks to Helge and Layer for help with the $iFlag update ;=============================================================================== Func _FileListToArray($sPath, $sFilter = "*", $iFlag = 0) Local $hSearch, $sFile, $asFileList[1] If Not FileExists($sPath) Then SetError(1) Return "" EndIf If (StringInStr($sFilter, "\")) or (StringInStr($sFilter, "/")) or (StringInStr($sFilter, ":")) or (StringInStr($sFilter, ">")) or (StringInStr($sFilter, "<")) or (StringInStr($sFilter, "|")) or (StringStripWS($sFilter, 8) = "") Then SetError(2) Return 0 EndIf If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then SetError(3) Return "" EndIf $asFileList[0] = 0 $hSearch = FileFindFirstFile($sPath & "\" & $sFilter) If $hSearch = -1 Then SetError(0) Return 0 EndIf While 1 $sFile = FileFindNextFile($hSearch) If @error Then ExitLoop If $iFlag = 1 Then If StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") <> 0 Then ContinueLoop EndIf If $iFlag = 2 Then If StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") = 0 Then ContinueLoop EndIf ReDim $asFileList[UBound($asFileList) + 1] $asFileList[0] = $asFileList[0] + 1 $asFileList[UBound($asFileList) - 1] = $sFile WEnd FileClose($hSearch) SetError(0) If $asFileList[0] = 0 Then Return "" Return $asFileList EndFunc;==>_FileListToArray Edited May 10, 2006 by rbhkamal "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
Developers Jos Posted May 10, 2006 Developers Share Posted May 10, 2006 Looked again an seems like there is duplicated cases where @error is set to 0 1- No files found @error = 02- Success @error = 0However if you switch number (1) to @error=1 then the return will be 1 then:1-No files found @error = 12-Path not Valid @error = 1and more...............Uh No idea what you are trying to tell me here.To me its like defined in the UDF:; @Error=1 Path not found or invalid; @Error=2 Invalid $sFilter; @Error=3 Invalid $iFlagAnd the UDF will return 0/@error 0 when no file is selected by the FileFilter. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
rbhkamal Posted May 10, 2006 Author Share Posted May 10, 2006 (edited) No idea what you are trying to tell me here.To me its like defined in the UDF:; @Error=1 Path not found or invalid; @Error=2 Invalid $sFilter; @Error=3 Invalid $iFlagAnd the UDF will return 0/@error 0 when no file is selected by the FileFilter.lol ... Sorryok.This function will set @error to 0 when there are no files found or the Function was successfull.make sence?Edit: Isn't that a problem? Edited May 10, 2006 by rbhkamal "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
Developers Jos Posted May 10, 2006 Developers Share Posted May 10, 2006 (edited) lol ... Sorryok.This function will set @error to 0 when there are no files found or the Function was successfull.make sence?Edit: Isn't that a problem?Don't know if not finding a file is an error or not.The other Errors are true errors .... Don't think we should make changes unless it is broke because we might brake scripts using this function... Edited May 10, 2006 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
rbhkamal Posted May 10, 2006 Author Share Posted May 10, 2006 (edited) Don't know if not finding a file is an error or not.The other Errors are true errors .... Don't think we should make changes unless it is broke because we might brake scripts using this function...How about you set Error to some thing new like 6 or 4 this way no one will have problems.(maybe)Edit: You will have to change it anyway because thsi function sets @error to 1 when the dir is invalid but the help file say it should be 2.I don't think anyone used it yet......It's also called BETAanyway thanks. Edited May 10, 2006 by rbhkamal "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
seandisanti Posted May 10, 2006 Share Posted May 10, 2006 (edited) How about you set Error to some thing new like 6 or 4 this way no one will have problems.(maybe)Edit: You will have to change it anyway because thsi function sets @error to 1 when the dir is invalid but the help file say it should be 2.I don't think anyone used it yet......It's also called BETAanyway thanks.i know this isn't constructive, i just wanted to say i'm anxiously waiting on responses to those lines... wonder if Valik is on... ***edit*** too much energy drink today, fingers moving faster than brain... Edited May 10, 2006 by cameronsdad Link to comment Share on other sites More sharing options...
Developers Jos Posted May 11, 2006 Developers Share Posted May 11, 2006 How about you set Error to some thing new like 6 or 4 this way no one will have problems.(maybe)Edit: You will have to change it anyway because thsi function sets @error to 1 when the dir is invalid but the help file say it should be 2.I don't think anyone used it yet......It's also called BETAanyway thanks.Well I was thinking changing the Helpfile and update it with the correct info... not the UDF ... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
rbhkamal Posted May 11, 2006 Author Share Posted May 11, 2006 Well I was thinking changing the Helpfile and update it with the correct info... not the UDF ...The only way to know that no files where found is by running the IsArray() check on the return value.(I think)You might want to put this as a note in the help file. "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix 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