Jump to content

rudolph

Members
  • Posts

    7
  • Joined

  • Last visited

rudolph's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Excellent Erezlevi: Normally the default is ASCII, but in this case was BINARY extrange. Anyway, I passed the flag ascii and It works . Thank you very much for your help.
  2. Hi all: I am using UDF FTP.au3, to upload a text file from windows Xp sp2 to unix ftp server, the scrip is running well but I found a BIG PROBLEM, maybe a BUG in FTP.au3 when the file test.txt is uploaded, the file was changed and added a carriage return(CR) and a line feed (LF) for , for each line . Someone can tell me what is wrong with my script or is a FTP.au3 BUG? Please I need a HELP on this ? CR=carriage return LF=Line feed For example , original file test.txt looks like this: aaaaaaaaaaaaabbbbbbbbb123456CR bbbbbbbbbbbbbbbbbbbbbbbbbbbbCR ddddddddddddddddddddddddddddCR The new uploaded file test.txt looks like this (Inserted CR and LF for each line): aaaaaaaaaaaaabbbbbbbbbccccccCR CR LFbbbbbbbbbbbbbbbbbbbbbbbbbbbbCR CR LFddddddddddddddddddddddddddddCR CODEOpt ("ExpandEnvStrings", 0)Opt ("ExpandVarStrings", 1) Opt ("MustDeclareVars", 1) ;;#include <GUIConstants.au3> #include <FTP.au3> Dim $server = "ftp.test.com" Dim $username = "usr" Dim $pass = "passw" Dim $port = 21 Dim $dllhandle = DllOpen('wininet.dll') Dim $Open = _FTPOpen('MyFTP') if @error Then MsgBox(0, "", "fail_open") Exit EndIf Dim $Conn = _FTPConnect($Open, $server, $username, $pass, $port) If @error Then MsgBox(0, "", "fail_Connect") Exit EndIf Dim $Ftpp = _FtpPutFile($Conn, 'C:\TEMP\test.txt', '/test.txt') If @error Then MsgBox(0, "", "fail_PutFile") Exit EndIf Dim $Ftpc = _FTPClose($Open) If @error Then MsgBox(0, "", "fail_Close") Exit EndIf DllClose($dllhandle) MsgBox(0,"FTP PUT File - Status ", ""$Ftpc = " & $Ftpc" & "$Open = " & $Open & @CRLF & "$Conn = " & $Conn & @CRLF & "$Ftpp = " & $Ftpp & @CRLF & "$Ftpc = " & $Ftpc ) Exit
  3. Hi all: I am using UDF FTP.au3, to upload a text file from windows Xp sp2 to unix ftp server, the scrip is running well but I found a BIG PROBLEM, maybe a BUG in FTP.au3 when the file test.txt is uploaded, the file was changed and added a carriage return(CR) and a line feed (LF) for , for each line . Someone can tell me what is wrong with my script or is a FTP.au3 BUG? Please I need a HELP on this ? CR=carriage return LF=Line feed For example , original file test.txt looks like this: aaaaaaaaaaaaabbbbbbbbb123456CR bbbbbbbbbbbbbbbbbbbbbbbbbbbbCR ddddddddddddddddddddddddddddCR The new uploaded file test.txt looks like this (Inserted CR and LF for each line): aaaaaaaaaaaaabbbbbbbbbccccccCR CR LFbbbbbbbbbbbbbbbbbbbbbbbbbbbbCR CR LFddddddddddddddddddddddddddddCR CODEOpt ("ExpandEnvStrings", 0)Opt ("ExpandVarStrings", 1) Opt ("MustDeclareVars", 1) ;;#include <GUIConstants.au3> #include <FTP.au3> Dim $server = "ftp.test.com" Dim $username = "usr" Dim $pass = "passw" Dim $port = 21 Dim $dllhandle = DllOpen('wininet.dll') Dim $Open = _FTPOpen('MyFTP') if @error Then MsgBox(0, "", "fail_open") Exit EndIf Dim $Conn = _FTPConnect($Open, $server, $username, $pass, $port) If @error Then MsgBox(0, "", "fail_Connect") Exit EndIf Dim $Ftpp = _FtpPutFile($Conn, 'C:\TEMP\test.txt', '/test.txt') If @error Then MsgBox(0, "", "fail_PutFile") Exit EndIf Dim $Ftpc = _FTPClose($Open) If @error Then MsgBox(0, "", "fail_Close") Exit EndIf DllClose($dllhandle) MsgBox(0,"FTP PUT File - Status ", ""$Ftpc = " & $Ftpc" & "$Open = " & $Open & @CRLF & "$Conn = " & $Conn & @CRLF & "$Ftpp = " & $Ftpp & @CRLF & "$Ftpc = " & $Ftpc ) Exit
  4. Really Cool!!!! Thanks so much to Paulie and smashly for helping me on this. It works!!!!!!!!!!
  5. Hi everyone. I have a small question regarding label, I want to put a label in a GUI, but It should be Blinking, I can not find in the properties or styles of a Label to get blinking, Is it possible to do that? I create a small example here : CODE#include <GUIConstants.au3> $AForm1 = GUICreate("AForm1", 633, 447, 193, 125) $Label1 = GUICtrlCreateLabel("Error Message Here", 192, 48, 98, 17) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd
  6. Hi Martin: Thanks a million for finding the problem, I learned how to pass the variable from a loop to a function, even if it is global declared. Now, my program works perfectly. Again thanks for your help. Rudolph.
  7. Hello Everybody: I built a Gui with 2 Tabs (Tab0 , Tab1) and inside with a ListView of items (Desktop items, Myfavorites items). When I go to Tab0 and double click an item from ListView1, It works, I can get the correct Item Text in a message Box. But here is the problem, when I change to Tab1 and double click an item from ListView2, It gives me a wrong item text, Someone can help on this, please. I use the double click routine from Gary Frost. you can run the code below : #include <GUIConstants.au3> #include <GuiTab.au3> #include<array.au3> #include<_FileListToArrayNew2g.au3> Global Const $WM_NOTIFY = 0x004E Global Const $DebugIt = 1 ;ListView Events Global Const $NM_FIRST = 0 Global Const $NM_LAST = (-99) Global Const $NM_OUTOFMEMORY = ($NM_FIRST - 1) Global Const $NM_CLICK = ($NM_FIRST - 2) Global Const $NM_DBLCLK = ($NM_FIRST - 3) Global $j1 Global $av_ListViews[3];Array starts idx=0 Global $avTabs[10];Array starts idx=0 $Style1 = BitOR($WS_THICKFRAME, $WS_SIZEBOX) ;Creating the GUI $hGui = GUICreate("GUI Name",810, 623, (@DesktopWidth - 800) / 2, (@DesktopHeight - 600) / 2,$WS_MAXIMIZEBOX + $WS_MINIMIZEBOX) ;; Create tab box $TabCtrl = GUICtrlCreateTab(10, 10, 580, 340) $av_ArrayTabs = _ArrayCreate("Programs", "Favorites"); Array of Tab names, starts in elem zero. ;Tab0 - Create Tab item 0 $avTabs[0] = GUICtrlCreateTabItem($av_ArrayTabs[0]) ;Load Desktop PROGRAMS LoadDesktopPgmInListView() _GUICtrlTabSetCurSel($TabCtrl, 0) ;;Tab1 - Create Tab item 1 $avTabs[1] = GUICtrlCreateTabItem($av_ArrayTabs[1]) LoadMyFavoritesURLInListView() _GUICtrlTabSetCurSel($TabCtrl, 1) GUICtrlCreateTabItem(""); Closes out the tabitems ; GUI Loop GUISetState() ;Register WM_NOTIFY events GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") While 1 $msg = GUIGetMsg() Switch $msg ;----------------------------------------------------------------------------------------- ;This case statement exits and updates code if needed Case $GUI_EVENT_CLOSE Exit ;----------------------------------------------------------------------------------------- ;put all the misc. stuff here Case Else ;;; EndSwitch WEnd ;;Insert items in ListView with Desktop Shortcuts Func LoadDesktopPgmInListView() $DesktopDir = @DesktopDir Local $sPath = $DesktopDir, $Flag=1, $Recurse=0, $BasDir=1, $filter = "*.lnk" $av_ArrayPaths = _FileListToArray3 ($sPath, $filter, $Flag, $Recurse, $BasDir);Get full paths of folders from Desktop, 0 elem=num occurences $Count = $av_ArrayPaths[0] $av_ListViews[0] = GUICtrlCreateListView("Applications ", 15, 30, 550, 350) ; First ListView _GUICtrlListViewSetColumnWidth ($av_ListViews[0], 0, 500) ; Size of the First Column 0, in the List view GUICtrlSendMsg($av_ListViews[0], $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) ;Gridlines GUICtrlSendMsg($av_ListViews[0], $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT) For $k = 1 To Number($Count) GUICtrlCreateListViewItem("item " & $k & " " & $av_ArrayPaths[$k], $av_ListViews[0]) Next EndFunc ;;Insert items in ListView with MyFavorites URL Func LoadMyFavoritesURLInListView() $FavoritesURL = @FavoritesDir Local $sPath = $FavoritesURL, $Flag=1, $Recurse=0, $BasDir=1, $filter = "*.url" $av_ArrayPaths = _FileListToArray3 ($sPath, $filter, $Flag, $Recurse, $BasDir);Get full paths of files from MyFavorites, 0 elem=num occurences $Count = $av_ArrayPaths[0] $av_ListViews[1] = GUICtrlCreateListView("MyFavorites URL ", 15, 30, 550, 350) ; Second ListView _GUICtrlListViewSetColumnWidth ($av_ListViews[1], 0, 500) ; Size of the First Column 0, in the List view GUICtrlSendMsg($av_ListViews[1], $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) ;Gridlines GUICtrlSendMsg($av_ListViews[1], $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT) For $k = 1 To Number($Count) GUICtrlCreateListViewItem("item " & $k & " " & $av_ArrayPaths[$k], $av_ListViews[1]) Next EndFunc ; WM_NOTIFY event handler Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $tagNMLISTVIEW , $event, $hwndFrom, $code $tagNMLISTVIEW = DllStructCreate("int;int;int;int;int;uint;uint;uint;int;int", $lParam);NMHDR (hwndFrom, idFrom, code), (iItem, iSubItem, uNewState, uOldState, uChanged, ptAction) If @error Then Return $event = DllStructGetData($tagNMLISTVIEW, 3) For $j1 = 0 To 2 If $wParam = $av_ListViews[$j1] Then if $event = $NM_DBLCLK Then MsgBox(0,"Double Clicked ctrlidLV = ", $av_ListViews[$j1]) ListView_DoubleClick () MsgBox(0, "exit loop:", "Tab" & $j1) ExitLoop EndIf EndIf Next $tagNMHDR = 0 $event = 0 $lParam = 0 EndFunc ;==>WM_Notify_Events Func _DebugPrint($s_text) $s_text = StringReplace($s_text, @LF, @LF & "-->") ConsoleWrite("!===========================================================" & @LF & _ "+===========================================================" & @LF & _ "-->" & $s_text & @LF & _ "+===========================================================" & @LF) EndFunc ;==>_DebugPrint Func ListView_Click() ;-----------------DISABLE ----------------------------------------------------------------------------- ;If $DebugIt Then _DebugPrint ("$NM_CLICK");; Writes to console ;---------------------------------------------------------------------------------------------- EndFunc ;==>ListView_Click Func ListView_DoubleClick() local $indiceselect ;---------------------------------------------------------------------------------------------- If $DebugIt Then _DebugPrint ("$NM_DBLCLK") ;---------------------------------------------------------------------------------------------- $indiceselect = _GUICtrlListViewGetSelectedIndices($av_ListViews[$j1]) MsgBox(0,"Double Clicked", _GUICtrlListViewGetItemText($av_ListViews[$j1], $indiceselect) ) EndFunc ;==>ListView_DoubleClick Also here is the Function, _FileListToArrayNew2g.au3 if someone can not find it: #include-once #include<array.au3> ;~ #include "_GUILV1.au3" ;~ #AutoIt3Wrapper_useansi=y ;=============================================================================== ; ; Description: lists all files and folders in a specified path ; Syntax: _FileListToArray($s_Path, $s_Filter = "*", $i_Flag = 0) ; Parameter(s): $s_Path = Path to generate filelist for ; $s_Filter = The filter to use. Search the Autoit3 manual for the word "WildCards" For details ; $i_Flag = determines whether to return file or folders or both ; $i_Flag=0(Default) Return both files and folders ; $i_Flag=1 Return files Only ; $i_Flag=2 Return Folders Only ; $i_Recurse = Indicate whether recursion to subfolders required ; $i_Recurse=0(Default) No recursion to subfolders ; $i_Recurse=1 recursion to subfolders ; $i_BaseDir = Indicate whether base directory name included in returned elements ; $i_BaseDir=0 base directory name not included ; $i_BaseDir=1 (Default) base directory name included ; $s_Exclude= The Exclude filter to use. "WildCards" For details ; ; 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 the an empty string "" if no files are found and sets @Error on errors ; @Error=1 Path not found or invalid ; @Error=2 Invalid $s_Filter ; @Error=3 Invalid $i_Flag ; @Error=4 No File(s) Found ; ; Author(s): randallc <randallc@ozemail.com.au>; modified from SolidSnake and big_daddy and SmoKE_N and GEOsoft! ; 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 ; ;=============================================================================== Func _FileListToArray3($sPath, $sFilter = "*", $iFlag = 0, $iRecurse = 0, $iBaseDir = 1, $sExclude = ""); ** still need to use RegExp to eliminate dupes? *** If $sFilter = -1 Then $sFilter = "*" If StringRight($sPath, 1) == "\" Then $sPath = StringTrimRight($sPath, 1) Local $hSearch, $sFile, $sFileString, $asList[1], $sep = "|", $sFileString1, $sFilter1 = $sFilter If Not FileExists($sPath) Then Return SetError(1, 1, "") If (StringInStr($sFilter, "\")) Or (StringInStr($sFilter, "/")) Or (StringInStr($sFilter, ":")) Or (StringInStr($sFilter, ">")) Or (StringInStr($sFilter, "<")) Or (StringStripWS($sFilter, 8) = "") Then Return SetError(2, 2, "") If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "") $sFilter = StringReplace("*" & $sFilter & "*", "**", "*") If Not StringInStr($sFilter, ';') And Not StringInStr($sFilter, '|') Then $sFilter &= "|" If StringInStr($sFilter, ';') Then $sep = ";";$sFilter &= ';' Local $aSplit = StringSplit(StringStripWS($sFilter, 8), $sep), $sRead, $sHoldSplit, $arFolders[2] = [ $sPath, ""] $cw = ConsoleWrite("UBound($aSplit) =" & UBound($aSplit) & @LF) If $sExclude <> "" Then $sExclude = "(?i)" & StringReplace(StringReplace(StringReplace($sExclude, ".", "\."), "*", ".*"), "?", ".");change the filters to RegExp filters If $iRecurse Then;$cw = ConsoleWrite("UBound($aSplit) =" & UBound($aSplit) & @LF) If $iFlag = 2 Then _FileListToArrayFolders($sPath, $sFileString1, "*", $iRecurse, $sExclude) If $iFlag <> 2 Then _FileListToArrayFolders($sPath, $sFileString1, "*", $iRecurse, "") Local $arFolders = StringSplit(StringTrimRight($sFileString1, 1), "*") $arFolders[0] = $sPath EndIf For $iCF = 0 To UBound($arFolders) - 1; $cw = ConsoleWrite("$iCF=" & $iCF & " $arFolders[$iCF] =" & @LF & $arFolders[$iCF] & @LF) If StringStripWS($arFolders[$iCF], 8) = '' Then ContinueLoop For $iCC = 1 To UBound($aSplit) - 1 If StringStripWS($aSplit[$iCC], 8) = '' Then ContinueLoop If StringLeft($aSplit[$iCC], 1) == "." Then $aSplit[$iCC] = "*" & $aSplit[$iCC];, "**", "*") Select; options for not recursing; quicker than filtering after for single directory Case Not $iRecurse And Not $iFlag And Not $iBaseDir; fastest, with files and folders, not recursed _FileListToArrayBrief2($arFolders[$iCF], $sFileString, $aSplit[$iCC], $sExclude) Case Not $iFlag; not $iRecurse and And $iBaseDir;fast, with files and folders, not recursed _FileListToArrayBrief1($arFolders[$iCF], $sFileString, $aSplit[$iCC], $sExclude) Case $iFlag = 1;fast, with files only, not recursed _FileListToArrayFiles($arFolders[$iCF], $sFileString, $aSplit[$iCC], $sExclude) Case Not $iRecurse And $iFlag = 2; folders only , not recursed _FileListToArrayFolders($arFolders[$iCF], $sFileString, $aSplit[$iCC], $iRecurse, $sExclude) EndSelect;$cw = ConsoleWrite("$iCC=" & $iCC & " $sFileString =" & @LF & $sFileString & @LF) If $iCF = 0 Then $sHoldSplit &= '|' & $aSplit[$iCC]; $cw = ConsoleWrite("$iCC=" & $iCC & " $sFileString =" & @LF & $sFileString & @LF) Next If $iCF = 0 Then $sFilter = StringReplace(StringTrimLeft($sHoldSplit, 1), "**", "*");,$cw = ConsoleWrite("$iCC=" & $iCC & " $sFilter =" & @LF & $sFilter & @LF) Next If $iRecurse And $iFlag = 2 And $sFilter <> "*" And $sFilter <> "*.*" Then; filter folders ------------------- $sFileString1 = StringTrimRight(StringReplace($sFileString1, "*", @CRLF), 1) $sFilter1 = StringReplace(StringReplace(StringReplace($sFilter1, ".", "\."), "*", ".*"), "?", ".");change the filters to RegExp filters Local $pattern = '(?m)(^(?i)' & $sFilter1 & '$)', $cw = ConsoleWrite("$sFilter =" & @LF & $sFilter1 & @LF), $cw = ConsoleWrite("$pattern =" & @LF & $pattern & @LF) Local $asList = StringRegExp($sFileString1, $pattern, 3) If (Not $iBaseDir) Then $sFileString1 = _ArrayToString($asList, "*") $sFileString1 = StringReplace($sFileString1, $sPath & "\", "", 0, 2) $asList = StringSplit($sFileString1, "*") EndIf ElseIf $iRecurse And $iFlag = 2 Then $sFileString = $sFileString1 EndIf;If UBound($asList) > 1 Then ConsoleWrite("$asList[1] =" & @LF & $asList[1] & @LF) If IsArray($asList) And UBound($asList) > 1 And $asList[0] <> "" Then Return $asList If (Not $iBaseDir) Or (Not $iRecurse And Not $iFlag And Not $iBaseDir) Then $sFileString = StringReplace($sFileString, $sPath & "\", "", 0, 2) $arReturn = StringSplit(StringTrimRight($sFileString, 1), "*");~ local $a=ConsoleWrite("$sFileString :"&@lf&StringReplace($sFileString,"|",@crlf)&@lf),$timerstamp1=TimerInit() If IsArray($arReturn) And UBound($arReturn) > 1 And $arReturn[1] <> "" And Not (UBound($aSplit) = 3 And $aSplit[2] == "") Then _deleteduplicate1($arReturn);and $arFolders[1]<>"" Return $arReturn;~ Return StringSplit(StringTrimRight($sFileString, 1), "*") EndFunc ;==>_FileListToArray3 ;=============================================================================== ; ; Description: _deleteduplicate1; deletes duplicates in an Array 1D [could be done faster with vbs func] ; Syntax: _deleteduplicate1(ByRef $ar_Array) ; Parameter(s): $ar_Array = 1d Array ; Requirement(s): None ; Return Value(s): On Success - Returns asorted array with no duplicates ; On Failure - ; @Error=1 P ; @Error=2 ; ; Author(s): randallc ;=============================================================================== Func _deleteduplicate1(ByRef $ar_Array) Local $ar_New[1], $timerstamp1 = TimerInit(), $s_New _ArrayDelete($ar_Array, 0) ConsoleWrite("UBound($ar_Array) =" & UBound($ar_Array) & @LF) _ArraySort($ar_Array) Local $count = UBound($ar_Array) - 1, $a = ConsoleWrite("_ArraySort :" & Round(TimerDiff($timerstamp1)) & " mseconds " & @LF), $timerstamp1 = TimerInit() For $x = $count - 1 To 0 Step - 1 $Itemtxt1 = $ar_Array[ $x] Do If $x > 0 Then $Itemtxt2 = $ar_Array[ $x - 1] If StringUpper($Itemtxt1) == StringUpper($Itemtxt2) Then $count -= 1 $x -= 1 EndIf EndIf Until StringUpper($Itemtxt1) <> StringUpper($Itemtxt2) Or $x = 0 $s_New &= $Itemtxt1 & "|" Next $ar_Array = StringSplit($s_New, "|") Local $a = ConsoleWrite("_ArrayAdd :" & Round(TimerDiff($timerstamp1)) & " mseconds " & @LF), $timerstamp1 = TimerInit() If $ar_Array [UBound($ar_Array) - 1] == "" Then _ArrayDelete($ar_Array, UBound($ar_Array) - 1) _ArrayReverse($ar_Array, 1) If $ar_Array [UBound($ar_Array) - 1] == "" Then _ArrayDelete($ar_Array, UBound($ar_Array) - 1) ConsoleWrite("_ArrayReverse :" & Round(TimerDiff($timerstamp1)) & " mseconds " & @LF) Return 1 EndFunc ;==>_deleteduplicate1 ;=============================================================================== ; ; Description: Helper self-calling func for _FileListToArray wrapper; lists all folders in a specified path ; Syntax: _FileListToArrayFolders($s_PathF, ByRef $s_FileStringF, $s_FilterF, $i_RecurseF) ; Parameter(s): $s_PathF = Path to generate filelist for ; $s_FileStringF = The string for lists all folders only in a specified path ; $s_FilterF = The filter to use. Search the Autoit3 manual for the word "WildCards" For details ; $i_RecurseF = Indicate whether recursion to subfolders required ; $i_RecurseF=0(Default) No recursion to subfolders ; $i_RecurseF=1 recursion to subfolders ; $sExcludeF= The Exclude filter to use. "WildCards" For details ; 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 the an empty string "" if no files are found and sets @Error on errors ; @Error=1 Path not found or invalid ; @Error=2 Invalid $s_Filter ; @Error=3 Invalid $i_Flag ; @Error=4 No File(s) Found ; ; Author(s): randallc; modified from SolidSnake, SmoKe_N, GEOsoft and big_daddy ;=============================================================================== Func _FileListToArrayFolders($sPathF, ByRef $sFileStringF, $sFilterF, $iRecurseF, $sExcludeF = "") Local $hSearch = FileFindFirstFile($sPathF & "\" & $sFilterF), $sPathF2 If $hSearch = -1 Then Return SetError(4, 4, "") If $sExcludeF == "" Then While 1 $sFileF = FileFindNextFile($hSearch) If @error Then SetError(0) ExitLoop EndIf $sPathF2 = $sPathF & "\" & $sFileF If StringInStr(FileGetAttrib($sPathF2), "D") Then;directories only wanted; and the attrib shows is directory $sFileStringF &= $sPathF2 & "*";this writes the filename to the delimited string with * as delimiter If $iRecurseF = 1 Then _FileListToArrayFolders($sPathF2, $sFileStringF, $sFilterF, $iRecurseF) EndIf WEnd Else While 1 $sFileF = FileFindNextFile($hSearch) If @error Then SetError(0) ExitLoop EndIf $sPathF2 = $sPathF & "\" & $sFileF; if folders only and this pattern matches exclude pattern, no further list or subdir If StringRegExp($sPathF2, $sExcludeF) Then ContinueLoop If StringInStr(FileGetAttrib($sPathF2), "D") Then;directories only wanted; and the attrib shows is directory $sFileStringF &= $sPathF2 & "*";this writes the filename to the delimited string with * as delimiter with * as delimiter If $iRecurseF = 1 Then _FileListToArrayFolders($sPathF2, $sFileStringF, $sFilterF, $iRecurseF, $sExcludeF) EndIf WEnd EndIf FileClose($hSearch) EndFunc ;==>_FileListToArrayFolders ;=============================================================================== ; ; Description: Helper func for _FileListToArray wrapper; lists all files and folders in a specified path ; Syntax: _FileListToArrayFiles($s_PathF, ByRef $s_FileStringF, $s_FilterF);quick as not recursive ; Parameter(s): $s_PathF = Path to generate filelist for ; $s_FileStringF = The string for lists all files and folders in a specified path ; $s_FilterF = The filter to use. Search the Autoit3 manual for the word "WildCards" For details ; $sExcludeF= The Exclude filter to use. "WildCards" For details ; 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 the an empty string "" if no files are found and sets @Error on errors ; @Error=1 Path not found or invalid ; @Error=2 Invalid $s_Filter ; @Error=4 No File(s) Found ; ; Author(s): randallc; modified from SolidSnake, SmoKe_N, GEOsoft and big_daddy ;=============================================================================== Func _FileListToArrayFiles($sPathF, ByRef $sFileStringF, $sFilterF, $sExcludeF = "") Local $hSearch = FileFindFirstFile($sPathF & "\" & $sFilterF), $sPathF2 If $hSearch = -1 Then Return SetError(4, 4, "") If $sExcludeF == "" Then While 1 $sFileF = FileFindNextFile($hSearch) If @error Then SetError(0) ExitLoop EndIf $sPathF2 = $sPathF & "\" & $sFileF;directories not wanted; and the attrib shows not directory If Not StringInStr(FileGetAttrib($sPathF2), "D") Then $sFileStringF &= $sPathF2 & "*";this writes the filename to the delimited string with * as delimiter WEnd Else While 1 $sFileF = FileFindNextFile($hSearch) If @error Then SetError(0) ExitLoop EndIf $sPathF2 = $sPathF & "\" & $sFileF;directories not wanted; and the attrib shows not directory; and filename [only] does not match exclude If Not StringInStr(FileGetAttrib($sPathF2), "D") _ And Not StringRegExp($sFileF, $sExcludeF) Then $sFileStringF &= $sPathF2 & "*";this writes the filename to the delimited string with * as delimiter WEnd EndIf FileClose($hSearch) EndFunc ;==>_FileListToArrayFiles ;=============================================================================== ; ; Description: Helper self-calling func for _FileListToArray wrapper; lists all files and folders in a specified path ; Syntax: _FileListToArrayRecFiles($s_PathF, ByRef $s_FileStringF, $s_FilterF); recursive ; Parameter(s): $s_PathF = Path to generate filelist for ; $s_FileStringF = The string for lists all files and folders in a specified path ; $s_FilterF = The filter to use. Search the Autoit3 manual for the word "WildCards" For details ; $sExcludeF= The Exclude filter to use. "WildCards" For details ; 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 the an empty string "" if no files are found and sets @Error on errors ; @Error=1 Path not found or invalid ; @Error=2 Invalid $s_Filter ; @Error=4 No File(s) Found ; ; Author(s): randallc; modified from SolidSnake, SmoKe_N, GEOsoft and big_daddy ;=============================================================================== Func _FileListToArrayRecAll($sPathF, ByRef $sFileStringF, $sFilterF, $sExcludeF = "") Local $hSearch = FileFindFirstFile($sPathF & "\" & $sFilterF), $sPathF2 If $hSearch = -1 Then Return SetError(4, 4, "") If $sExcludeF == "" Then While 1 $sFileF = FileFindNextFile($hSearch) If @error Then SetError(0) ExitLoop EndIf $sPathF2 = $sPathF & "\" & $sFileF $sFileStringF &= $sPathF2 & "*";this writes the filename to the delimited string with * as delimiter If StringInStr(FileGetAttrib($sPathF2), "D") Then _FileListToArrayRecAll($sPathF2, $sFileStringF, $sFilterF);, $iFlagF, $iRecurseF) WEnd Else While 1 $sFileF = FileFindNextFile($hSearch) If @error Then SetError(0) ExitLoop EndIf $sPathF2 = $sPathF & "\" & $sFileF If StringInStr(FileGetAttrib($sPathF2), "D") Then $sFileStringF &= $sPathF2 & "*";this writes the directoryname _FileListToArrayRecAll($sPathF2, $sFileStringF, $sFilterF, $sExcludeF);, $iFlagF, $iRecurseF) Else;if not directory, check Exclude match If Not StringRegExp($sFileF, $sExcludeF) Then $sFileStringF &= $sPathF2 & "*";this writes the filename to the delimited string with * as delimiter EndIf WEnd EndIf FileClose($hSearch) EndFunc ;==>_FileListToArrayRecAll ;=============================================================================== ; ; Description: Helper self-calling func for _FileListToArray wrapper; lists all files in a specified path ; Syntax: _FileListToArrayRecFiles($s_PathF, ByRef $s_FileStringF, $s_FilterF); recursive ; Parameter(s): $s_PathF = Path to generate filelist for ; $s_FileStringF = The string for lists all files and folders in a specified path ; $s_FilterF = The filter to use. Search the Autoit3 manual for the word "WildCards" For details ; $sExcludeF= The Exclude filter to use. "WildCards" For details ; 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 the an empty string "" if no files are found and sets @Error on errors ; @Error=1 Path not found or invalid ; @Error=2 Invalid $s_Filter ; @Error=4 No File(s) Found ; ; Author(s): randallc; modified from SolidSnake, SmoKe_N, GEOsoft and big_daddy ;=============================================================================== Func _FileListToArrayRecFiles($sPathF, ByRef $sFileStringF, $sFilterF, $sExcludeF = "") Local $hSearch = FileFindFirstFile($sPathF & "\" & $sFilterF), $sPathF2 If $hSearch = -1 Then Return SetError(4, 4, "") If $sExcludeF == "" Then While 1 $sFileF = FileFindNextFile($hSearch) If @error Then SetError(0) ExitLoop EndIf $sPathF2 = $sPathF & "\" & $sFileF If StringInStr(FileGetAttrib($sPathF2), "D") Then _FileListToArrayRecFiles($sPathF2, $sFileStringF, $sFilterF);, $iFlagF, $iRecurseF) Else $sFileStringF &= $sPathF2 & "*";this writes the filename to the delimited string with * as delimiter EndIf WEnd Else While 1 $sFileF = FileFindNextFile($hSearch) If @error Then SetError(0) ExitLoop EndIf $sPathF2 = $sPathF & "\" & $sFileF If StringInStr(FileGetAttrib($sPathF2), "D") Then _FileListToArrayRecFiles($sPathF2, $sFileStringF, $sFilterF, $sExcludeF);, $iFlagF, $iRecurseF) Else If Not StringRegExp($sFileF, $sExcludeF) Then $sFileStringF &= $sPathF2 & "*";this writes the filename to the delimited string with * as delimiter EndIf WEnd EndIf FileClose($hSearch) EndFunc ;==>_FileListToArrayRecFiles ;=============================================================================== ; ; Description: Helper func for _FileListToArray wrapper; lists all files ONLY in a specified path ; Syntax: _FileListToArrayBrief2($s_PathF, ByRef $s_FileStringF, $s_FilterF);quick as not recursive ; Parameter(s): $s_PathF = Path to generate filelist for ; $s_FileStringF = The string for lists all files and folders in a specified path ; $s_FilterF = The filter to use. Search the Autoit3 manual for the word "WildCards" For details ; $sExcludeF= The Exclude filter to use. "WildCards" For details ; 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 the an empty string "" if no files are found and sets @Error on errors ; @Error=1 Path not found or invalid ; @Error=2 Invalid $s_Filter ; @Error=4 No File(s) Found ; ; Author(s): randallc; modified from SolidSnake, SmoKe_N, GEOsoft and big_daddy ;=============================================================================== Func _FileListToArrayBrief2($sPathF, ByRef $sFileStringF, $sFilterF, $sExcludeF = "") $hSearch = FileFindFirstFile($sPathF & "\" & $sFilterF) If $hSearch = -1 Then Return SetError(4, 4, "") If $sExcludeF == "" Then While 1 $sFileF = FileFindNextFile($hSearch) If @error Then SetError(0) ExitLoop EndIf $sFileStringF &= $sFileF & "*";this writes the filename to the delimited string with * as delimiter; only time no full path included WEnd Else While 1 $sFileF = FileFindNextFile($hSearch) If @error Then SetError(0) ExitLoop EndIf;If not StringRegExp($sFileF,$sExcludeF) then $sFileStringF &= $sPathF2 & "*" If Not StringRegExp($sFileF, $sExcludeF) Then $sFileStringF &= $sFileF & "*";this writes the filename to the delimited string with * as delimiter; only time no full path included WEnd EndIf FileClose($hSearch) EndFunc ;==>_FileListToArrayBrief2 ;=============================================================================== ; ; Description: Helper func for _FileListToArray wrapper; lists all files and folders in a specified path ; Syntax: _FileListToArrayBrief1($s_PathF, ByRef $s_FileStringF, $s_FilterF);quick as not recursive ; Parameter(s): $s_PathF = Path to generate filelist for ; $s_FileStringF = The string for lists all files and folders in a specified path ; $s_FilterF = The filter to use. Search the Autoit3 manual for the word "WildCards" For details ; $sExcludeF= The Exclude filter to use. "WildCards" For details ; 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 the an empty string "" if no files are found and sets @Error on errors ; @Error=1 Path not found or invalid ; @Error=2 Invalid $s_Filter ; @Error=4 No File(s) Found ; ; Author(s): randallc; modified from SolidSnake, SmoKe_N, GEOsoft and big_daddy ;=============================================================================== Func _FileListToArrayBrief1($sPathF, ByRef $sFileStringF, $sFilterF, $sExcludeF = "") $hSearch = FileFindFirstFile($sPathF & "\" & $sFilterF) If $hSearch = -1 Then Return SetError(4, 4, "") If $sExcludeF == "" Then While 1 $sFileF = FileFindNextFile($hSearch) If @error Then SetError(0) ExitLoop EndIf $sFileStringF &= $sPathF & "\" & $sFileF & "*";this writes the filename to the delimited string with * as delimiter [remo] WEnd Else While 1 $sFileF = FileFindNextFile($hSearch) If @error Then SetError(0) ExitLoop EndIf If Not StringRegExp($sFileF, $sExcludeF) Then $sFileStringF &= $sPathF & "\" & $sFileF & "*";this writes the filename to the delimited string with * as delimiter [remo] WEnd EndIf FileClose($hSearch) EndFunc ;==>_FileListToArrayBrief1
×
×
  • Create New...