Copy link to clipboard
Copied
Dear all,
I'm looking for a script to enable the display of the (animated) progress bar during the execution of any kind of script.
I tried various combinations with this code found on the forum, without success :
var tObj = app.thermometer;
tObj.duration = 1000000;
tObj.begin();
tObj.value=i;
for(var i=0;i<100000;i++)
{ tObj.text = "Processing, please wait";}
tObj.end();
I only succeded to display the progress bar window, but... without animation during the process of the function.
Would anyone have an idea how to combine this code with the execution of a function in order to see the animated progress bar during the execution of that function?
Thank you in advance and best regards.
Copy link to clipboard
Copied
Try this:
var tObj = app.thermometer;
tObj.duration = 1000000;
tObj.begin();
for(var i=0;i<100000;i++)
{
tObj.value=i;
tObj.text = "Processing, please wait";
}
tObj.end();
Copy link to clipboard
Copied
Thanks for your messaqe.
I inserted my script just before "tObj.end()" (is it correct ?)
Now, I can see the progress bar moving... but, only before the process of my script.
When the chronometer stops (and so do the progress bar), my script starts but the progress bar is not progressing anymore during the execution of my script.
Is there a way to do it differently ?
Copy link to clipboard
Copied
You must change the value of tObj in your script.
Copy link to clipboard
Copied
Would you please be kind enough to help me with the correct code ?
I do not know Javascript well enough and I have no clue how to do...
Copy link to clipboard
Copied
Changing tObj.value will change the display of the progress bar.
In your code you can change the value with:
tObj.value++;
Copy link to clipboard
Copied
You have to decide at what point in YOUR code you want the thermometer to change. It's entirely up to you, not magic. You have to also decide what the "duration" is. For example if you process 127 pages and update value for each page, you might well set duration to 127. If you're checking 207 form fields, and want to update for each field, set duration to 207. It's YOUR code. Take control.
Copy link to clipboard
Copied
In addition to all that was mentioned above, I would changes this line:
tObj.text = "Processing, please wait";
To show the actual value being processed, like this:
tObj.text = "Processing, please wait... (" + i + "/1000000)";
Or something like that... Otherwise there's no real reason to place it inside the loop, since the text never changes.
And by the way, because your loop basically does nothing (except for updating the thermometer), it will appear and disappear in less than a second, most likely.
Copy link to clipboard
Copied
Looks like that the OP copies the code from here:
Copy link to clipboard
Copied
Yeah, it doesn't make sense there, either. It just seems like a way to delay the script while something is loading in the background, but since JS is synchronous by definition I don't think it will matter much.
Copy link to clipboard
Copied
I am perplexed because I still have not understood how to make the thermother appear in a relevant way.
Let's imagine the following example:
I have a script of 500 lines that process one by one some fields of a document (some pass to hidden, some to visible, and others to readonly.
how should I write and place the thermometer so that the progress bar progresses as the fields are processed?
Copy link to clipboard
Copied
Do you have a loop that iterates over those fields? If so, initiate the thermometer before the loop starts, change its value and/or text inside the loop, and end it after the loop finishes. If you want more exact instructions you will need to post your actual code.
Copy link to clipboard
Copied
Some of my scripts contain a loop, some not.
I will soon post examples, as you suggest.
Copy link to clipboard
Copied
Without a loop there isn't much point to using a thermometer, although it's still possible.
Copy link to clipboard
Copied
You can update the thermometer by adding extra lines inside your 500 line script, as often and as many as you want.