Show progress on long running scripts

I have long running script that runs from the Control application after the users has selected the parameters.

Does anybody have any idea how I and where I can add a progress bar/indication that process is running?

1 Like

I have been asking for this since I started with scriptcase. It is possible to use third party software to do this but a progress bar widget of some sort built in would be insanely useful.

1 Like

Do you have an example third party that works?
Also noticed that in the External Libraries there is a progressBar from Pace, but I have no idea how to use it :slight_smile: :rofl:
Also look at this post from ScottMarting Progress bar in Scriptcase..! - #4 by ScottMartin
Not a progress bar, but better than nothing

Not that works well enough to show off. Cumbersome at best. Still working on it.

Revisa este vídeo.

2 Likes

I’ll give it a try. Gracias!

I have already started and is pretty good.
Just need to figure out how to use on long running scripts

Hi Claudio_Senel
Sorry but I only understand English.Could not understand but watched the process.
Thank you for the video, it helped a lot, but:not what I need or it it?
When using your example it shows a progress bar when the application loads.
My problem is that in the control application a user would select various options then click ok. There is a on onValidate PHP code that runs and can run for a long time. It is here that I need the progressbar to show and not when the Application loads.

1 Like

The difficult thing here is that you have no options to interact with your form directly as php is running on the server. If you know how many records you need to process then you can consider a strategy as the following: keep track of the current processed records in a global var or database. Create a (modal) form that has a piece of javascript that has a timer in it to request the current status, i.e. every 3 seconds. The javascript must start ondocumentready. So it is possible, and you can find timer javascript on the web. I’m only not that handy with integrating the javascript into Scriptcase.

2 Likes

sc9_202203271646_export_ProgressBar.zip (2.2 MB)
Ok, so here i my stab at this and I have uploaded the applications for you to download.
There are two application involved.

  1. The control application that captures parameters. In this case the duration in seconds
  2. A blank application that is the long running application.

The long running application uses a sleep statement to simulate a long running program.

Any comments or suggestion are welcome.

1 Like

I was able to do this using two blank applications. The use case is to loop through a set of daily csv log files and load the data into a temp table to do some database operations and display the results in a grid.

A user selects a start date and an end date in a control application along with some other parameters that will be used to filter the data from the csv. The onValidate of the control sets all of the dates between the start and end date in a global variable containing an array of each date. So if the user selected 3/28 as the start and 3/30 as the end, the array would be ~ {‘20220328’, ‘20220329’, ‘20220330’}. That matches the date format in the csv filenames.

The control redirects to the first blank app which contains HTML/AJAX, and that calls the 2nd blank app that runs the PHP to do the task.

The second blank app has a ‘foreach’ loop that goes through each date in the array that was passed from the original control. In increments a counter each time it loops. The total number of files to be processed is the count of members of the array, so the current progress percentage is the counter divided by the total.

On each loop the PHP in the second control runs a stored procedure on the SQL server to import the CSV, passing a filename parameter that is based on the dates in the array.

During each loop, the second blank app writes the percentage complete and a message to be displayed on the screen ("Currently processing file " . $datefilter . “.csv”) to a JSON encoded array in a text file.

The first blank app refreshes every 250ms and it reads from the JSON array in the text file. It uses the percentage to update the progress bar and displays the message below it.

I’m sure I didn’t come up with this myself - some of the comments in the code were definitely written by someone else. I either found it here on this forum or put it together from other sources online. I’d be happy to share the code if anyone wants to try to adapt it to their own use.

2 Likes