Lazarus

Free Pascal => Windows => Topic started by: jcmontherock on March 26, 2022, 11:47:24 am

Title: FindFirst loop
Post by: jcmontherock on March 26, 2022, 11:47:24 am
Under Windows 11, I wrote an application to synchronize files from my laptop to the desktop computer. I am using a FindFirst loop to check last "update date" and "creation date" of each file contained in  a volume. I want to show, in a Memo, a message indicating the number of files already processed, after each 2000 files. For that I count the file entries processed and write my message. In fact some messages to memo are lost. I tried to use "Application.ProcessMessages" or "Sleep(0)" after sending my text, but nothing works. Messages are randomly shown in the Memo. I also have a progressbar and get the same problem with it. Is somebody has an idea how to solve that ?
Title: Re: FindFirst loop
Post by: Thaddy on March 26, 2022, 11:56:13 am
FindFirst should not loop. It is FindNext that may loop.
Title: Re: FindFirst loop
Post by: winni on March 26, 2022, 12:35:30 pm
Hi!

Look at this example:

https://www.freepascal.org/docs-html/rtl/sysutils/findfirst.html (https://www.freepascal.org/docs-html/rtl/sysutils/findfirst.html)

Winni
Title: Re: FindFirst loop
Post by: Zoran on March 26, 2022, 02:05:53 pm
Here, on Windows 10, Memo works even without calling Application.ProcessMessages.
I don't have Win 11, but it is strange to me that it behaves differently, I believe it is more probable that you are doing something wrong.

Try the attached project. With Application.ProcessMessages, even ScrollBox with a label added to it for each line, gets regularly updated.

Title: Re: FindFirst loop
Post by: jcmontherock on March 27, 2022, 11:48:31 am
Thanks everybody. The Zoran's example works perfectly. So, finally I found that's a logical error was in my FindFirst, (with FindNext...::)) loop.

I do not find how to mark my question "solved". Nevertheless it is.
Title: Re: FindFirst loop
Post by: Bart on March 27, 2022, 12:28:08 pm
I do not find how to mark my question "solved". Nevertheless it is.

Edit your first post and then add [Solved] to the subject line.

Bart
TinyPortal © 2005-2018