Sign in to follow this  
Followers 0
MattX

In my loop wrong ?

5 posts in this topic

Can someone tell me why my loop is not working ? Or if I need to make a change - I can get the result when the files are already past the 10 mark but if they are less and then they pass the 10 mark the message box fails to pop up.....

#include <File.au3>
#include <Array.au3>

$filefolder = 'D:\Inputp'
$fileextension = '*.eml'
$FileList = _FileListToArray($filefolder, $fileextension);only list files with given extension

While 1
If $FileList[0] > 10 Then
    MsgBox(0, "number of file is:", $FileList[0])
Else
EndIf
WEnd

Share this post


Link to post
Share on other sites



  • You only do the _FileListToArray() once before the loop but it seems like you want the loop to check for changes. Move the _FileListToArray() to the start of the loop.
  • Also, you should add a Sleep() in there. Listing the files thousands of times per second seems overkill, no?
  • You are including Array.au3 but not using anything from there.
  • And finally, as the Else is optional, remove it if there's no code in there.
1 person likes this

Share this post


Link to post
Share on other sites

You're only checking the files once, and you're doing it outside of your loop. If you want to monitor the folder, you need to move this line "$FileList = _FileListToArray($filefolder, $fileextension)", inside of the While Wend loop, and also you might want to think about a way to exit that loop, because right now it's going to run until you kill the process.

1 person likes this

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Thanks - changed it:

#include <File.au3>
#include <Array.au3>

$filefolder = 'D:Inputp'
$fileextension = '*.eml'

While 1
$FileList = _FileListToArray($filefolder, $fileextension);only list files with given extension
If $FileList[0] > 10 Then
    MsgBox(0, "number of file is:", $FileList[0])
Else
EndIf
WEnd

Share this post


Link to post
Share on other sites

MattX,

I would add a check to make sure that I am returning files (see @error values in help file) and idle the CPU with a sleep(1000) (check every second)

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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