- Tracy Lamb
- PowerBuilder
- Thursday, 18 August 2022 04:50 PM UTC
Hi all,
I need to loop through a few records and if all conditions are met, run a program. This works fine for one record. The program I'm running requires user interaction. Is there a way to wait for the other program to close before moving to the next record? The other program is a C# program that prints a label. The user has to click Print to actually print the label, in case they want to change the print template or printer. So it could take 10 seconds, or 2 minutes.
My loop is working fine, but it launches the label program, then moves on to the next record. And launches the label program again. So I end up with 4 or 5 (possibly more) instances of the label program running. I put a 10 second delay in, which gives time for the program to launch and the user to click Print. But not much more time for anything else.
for li_x = 1 to li_SelectedCount
ll_WorkOrder = this.GetItemNumber(ll_SelectedRows[li_x], "workorder")
ls_finished = this.GetItemString(ll_SelectedRows[li_x], "certificate_done")
if IsNull(ls_finished) then
MessageBox("Print Label","Certificate is not started for WO# " + string(ll_WorkOrder))
elseif ls_finished = 'F' then
MessageBox("Print Label","Certificate not finished for WO# " + string(ll_WorkOrder))
else
Run(ls_file + " " + string(ll_WorkOrder))
//Add a pause
StartTime = Now()
DO
LOOP Until SecondsAfter(StartTime,Now()) > 10
end if
next
Thanks,
~~~Tracy
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.