10-10-2023 07:26 AM
I am working on a script that will display a custom progress bar using a SUD dialog box. The script uses a For loop inside the dialog box to iterate through a list of files in a folder and display each file name during the loop while also advancing the progress bar. Stripping the For loop down to the basics of this discussion, it looks like this:
for each file in fldr.Files
Text2.Text = file.Name
next
However, once I run the script that calls the sud file, the dialog box will not be shown until the For loop is finished, at which point Text2.Text shows the last file in the folder. I have been searching relentlessly for a way to bring the dialog box up immediately once the script runs to allow the Text2 object to show each file name during the loop, but I've failed. Any ideas what I'm missing here?
Solved! Go to Solution.
10-11-2023 07:24 AM
Hello sbazzle,
While a script is running, no PAINT messages are processed for the GUI. In order to be able to repaint controls in the dialog during a loop, the processing of the script must be interrupted and repainting must be forced. This can be achieved with the ProcessMessages command. Add the command inside your loop after the controls to be painted have been informed about the progress. I have attached a small example dialog that starts a loop and displays a progress bar.
Regards,
AnJalpaka
10-11-2023 07:32 AM
If you want to show the progress bar outside your dialog or your script, you can use a non modal dialog which only shows "Please wait..." and a progress bar with a percentage display value. In this case it is enough to use the Pause command within the loop.
Take a look at the attached script and dialog.
10-11-2023 08:16 AM
This was the answer. Thank you very much.