Sign in to follow this  
Followers 0
Zhelkus

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

3 posts in this topic

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?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Thanks a lot. Not-so-seamlessly learning through T&E. :)

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