How To Implement a Progress Bar

Forum post Progress Bar status changing talks about how to set up a progress bar. It said:

Note that in ExeOutput 2, this will be easier. Something like:

exo_runhescriptblock(“main.jauge.Value := 40;”);

Question. Is it now exo_runhescriptcom instead of exo_runhescriptblock?

And what’s the proper way to code this in a php script?

I searched and found the following for requesting a folder:

Function AskFolder: String;
Begin
Result := SelectDirectory(“Choose a folder”, “”);
End

And I placed this in my PHP script:

$dir = exo_return_hescriptcom(“UserMain.AskFolder”, “Error”);

It works great. But sometimes it can take more than 10-15 seconds to complete for a large directory of files. So I would like a progress bar to display during the wait. But I’m not sure where to place in the PHP script. Before the AskFolder like this:

exo_runhescriptcom(“main.jauge.Value := 40;”);
$dir = exo_return_hescriptcom(“UserMain.AskFolder”, “Error”);

which, BTW, does not work. Or do something else?

You could insert in your UserMain script this code:

procedure SetProgress(Value: String);
begin
 SetUIProp("ProgressBar", "Value", Value);
end;       

And then call from your PHP code:

exo_runhescriptcom("Main.SetProgress|50");

But the progress bar is also managed internally, for example, when loading a webpage, so your progress may be reset automatically when a page has finished loading for instance.

Like this:

exo_runhescriptcom(“Main.SetProgress|50”);
$dirx = exo_return_hescriptcom(“UserMain.AskFolder”, “Error”);

If so, not seeing a progress bar. I did enter the procedure SetProgress in UserMain.

The problem is that your webpage is loading so the browser handles the progress bar itself.
If your PHP script takes time to process, you should run it from JavaScript (AJAX call for instance) and let JavaScript manage the progress bar for instance.

Ok, thanks.

I have searched and tried at least a dozen JavaScript or AJAX examples and could not get any to work. Know any ones that work under ExeOutput?

Our demo has an AJAX example, you could check the source code to see how it works.

Hopefully last question. Where are the demos? I looked at my installation and online documentation and cannot find.

On the doc PHP SAMPLES, the following link does not work:

Please refer to the General Demonstration for demonstrations and PHP samples.

I actually did a simple workaround where program A does the get folder and displays progress (via text and an animated gif) then calls the program B to do the work (when it completes, the progress stuff goes away). But if you know of an AJAX solution to share, I’m sure others would appreciate it. Thank you for your help.