Recent

Author Topic: FindFirst loop  (Read 766 times)

jcmontherock

  • Full Member
  • ***
  • Posts: 136
FindFirst loop
« 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 ?

Thaddy

  • Hero Member
  • *****
  • Posts: 11764
Re: FindFirst loop
« Reply #1 on: March 26, 2022, 11:56:13 am »
FindFirst should not loop. It is FindNext that may loop.
Black themes should be banned.

winni

  • Hero Member
  • *****
  • Posts: 3119
Re: FindFirst loop
« Reply #2 on: March 26, 2022, 12:35:30 pm »

Zoran

  • Hero Member
  • *****
  • Posts: 1739
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: FindFirst loop
« Reply #3 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.


jcmontherock

  • Full Member
  • ***
  • Posts: 136
Re: FindFirst loop
« Reply #4 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.

Bart

  • Hero Member
  • *****
  • Posts: 4721
    • Bart en Mariska's Webstek
Re: FindFirst loop
« Reply #5 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