Sign in to follow this  
Followers 0
myspacee

exitloop

5 posts in this topic

#1 ·  Posted (edited)

hello to all,

want to understand 'exitloop' use, post guide example:

; Shows the filenames of all files in the current directory.
$search = FileFindFirstFile("*.*")  

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    
    MsgBox(4096, "File:", $file)
WEnd

; Close the search handle
FileClose($search)

my code is very similar but contains another while on top :

(used to check IN directory every 5 seconds)

While 1

; Shows the filenames of all files in the current directory.
$search = FileFindFirstFile("*.*")  

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    
    MsgBox(4096, "File:", $file)
WEnd

; Close the search handle
FileClose($search)

sleep(5000)
WEnd

FileFindNextFile($search) search for new files to compare with production ones

(often, more than one)

when finish, exitloop quit application and my monitor directory terminate. :)

how can i close only 'internal' while ?

thank you as usual,

m.

Edited by myspacee

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

@myspacee

Maybe...

Do
;something
 Until @error

Edit :

Do
    $file = FileFindNextFile($search) 
    MsgBox(4096, "File:", $file)
Until $file = -1 or @error

Cheers,FireFox

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Don't use the While function...use another loop such as Do or For...

Share this post


Link to post
Share on other sites

thank you both,

m.

Share this post


Link to post
Share on other sites

Maybe...

#Include <File.au3>

Global $Location = @HomeDrive
Global $Pause = 5000; miliseconds

$FileList=_FileListToArray($Location, "*", 1)

While 1
    Sleep($Pause)
    
    $FileList2=_FileListToArray($Location, "*", 1)
    
    If $FileList[0] <> $FileList2[0] Then
        MsgBox(0,"Notice", "There is a file change in this folder   " & @CRLF & $Location & "   ", 5)
        ; do something...
        Exit
    EndIf
    
WEnd

8)


NEWHeader1.png

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