Jump to content

@error flag won't kick in to stop infinite While loop


Recommended Posts

I've got an extremely simple script and there's this extremely weird problem bugging me horribly.

#include <File.au3>
#include <String.au3>

$workingdir = "D:\Downloads\Lots of Videos\cgi.flash\f\src\"

Dim $c = 0
$flashsearch = FileFindFirstFile($workingdir & "*.swf")

While 1
    If @error Then ExitLoop
    $c += 1
    ToolTip("Scanning... found: " & $c & @CRLF & _
            "Filename: " & FileFindNextFile($flashsearch) & @CRLF & _
            @error, 0, 0)
WEnd
FileClose($flashsearch)


Dim $flashes[$c + 1]
$flashes[0] = 0

The loop should stop when @error is set to 1... but it doesn't!! And the only thing I've got in that folder are flashes (.swf)! Could somebody point out my mistake plz?

Link to comment
Share on other sites

I think it's because ToolTip is setting the error to 0 and not FileFindNextFile()

#include <File.au3>
#include <String.au3>

$workingdir = "D:\Downloads\Lots of Videos\cgi.flash\f\src\"

Dim $c = 0
$flashsearch = FileFindFirstFile($workingdir & "*.swf")

While 1
   
    $c += 1
    $file = FileFindNextFile($flashsearch)
    If @error Then ExitLoop
    ToolTip("Scanning... found: " & $c & @CRLF & _
            "Filename: " & $file & @CRLF & _
            @error, 0, 0)
WEnd
FileClose($flashsearch)


Dim $flashes[$c + 1]
$flashes[0] = 0
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...