app.thermometer / Progress bar

Participant ,
Nov 06, 2017

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.

TOPICS
Acrobat SDK and JavaScript, Macintosh, Windows

Views

469

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

app.thermometer / Progress bar

Participant ,
Nov 06, 2017

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.

TOPICS
Acrobat SDK and JavaScript, Macintosh, Windows

Views

470

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 06, 2017 0
Adobe Community Professional ,
Nov 06, 2017

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();

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 06, 2017 0
Participant ,
Nov 06, 2017

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 ?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 06, 2017 0
Adobe Community Professional ,
Nov 06, 2017

Copy link to clipboard

Copied

You must change the value of tObj in your script.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 06, 2017 0
Participant ,
Nov 06, 2017

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...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 06, 2017 0
Adobe Community Professional ,
Nov 06, 2017

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++;

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 06, 2017 0
Most Valuable Participant ,
Nov 06, 2017

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 06, 2017 0
Most Valuable Participant ,
Nov 06, 2017

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 06, 2017 0
Adobe Community Professional ,
Nov 06, 2017

Copy link to clipboard

Copied

Looks like that the OP copies the code from here:

Progress bar (app.thermometer) ???

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 06, 2017 0
Most Valuable Participant ,
Nov 06, 2017

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 06, 2017 0
Participant ,
Nov 08, 2017

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?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 08, 2017 0
Most Valuable Participant ,
Nov 08, 2017

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 08, 2017 0
Participant ,
Nov 08, 2017

Copy link to clipboard

Copied

Some of my scripts contain a loop, some not.

I will soon post examples, as you suggest.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 08, 2017 0
Most Valuable Participant ,
Nov 08, 2017

Copy link to clipboard

Copied

Without a loop there isn't much point to using a thermometer, although it's still possible.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 08, 2017 0
Most Valuable Participant ,
Nov 08, 2017

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 08, 2017 0