DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Can't Display a SUD Dialog Box During a For Loop (Progress Bar project)

Solved!
Go to solution

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?

0 Kudos
Message 1 of 4
(905 Views)

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

0 Kudos
Message 2 of 4
(854 Views)
Solution
Accepted by topic author sbazzle

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.

 

 

0 Kudos
Message 3 of 4
(849 Views)

This was the answer.  Thank you very much.

0 Kudos
Message 4 of 4
(839 Views)