Jump to content

exitloop


myspacee
 Share

Recommended Posts

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
Link to comment
Share on other sites

@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
Link to comment
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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...