• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Using setTimeOut, setInterval, or other means, to delay script execution

Explorer ,
Feb 20, 2020 Feb 20, 2020

Copy link to clipboard

Copied

 

I have previously posted my Big Picture objective.  Here, I take a Big Step Back, to get a grip on this, in the simplest context I can think of [welcome advice from (try67)].  But I am hindered by perilous partial-understanding of scripting [enough rope to...].

 

I've reviewed the JavaScriptTM for Acrobat® API Reference.  I've scoured online references/suggestions/examples.  I've created a slew of test documents.  Almost without exception, they function 'dead in the water.'  I am missing some things basic, and fundamental.

 

I sense I get hung up on [despite awareness of need for precision]

  • distinguishing Acrobat-oriented JavaScript from HTML/browser-oriented use
  • syntax precision -- e.g. case sensitivity, quotation-marks-or-not, ...
  • app-level [Acrobat] vs. document-level vs. page-level management

 

I've considered setTimeOut, and setInterval, all sorts of ways.  Here's what seems the simplest case [courtesy Thom Parker, 2008].  Upon a Button Event:

 

app.alert("Hello World", 3);

 

This works, as seen in the attachment.

 

But then, on a separate Buttion, I try to trigger the Alert as a parameter of setTimeOut:

 

// Utilize setTimeout ( expression, timeout );
//where expression is the JavaScript code to run after timeout milliseconds have elapsed.
//
setTimeout (app.alert("Hello World", 3), 2000 );

 

This fails, as seen in the attachment.

 

I can readily imagine that an entirely different approach is called for.  But I am at a loss for insight/instinct as to whether this demands a defined routine/function/variables/declarations, etc., in what order, etc.  I bet a number of you can see, at a glance, where I'm way off base.

 

Commentary most appreciated.

 

TOPICS
Acrobat SDK and JavaScript

Views

4.5K

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
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 20, 2020 Feb 20, 2020

 

app.setTimeOut ('app.alert("Hello World", 3)', 2000 );

 

 

The script input is a string. And "setTimeOut" is a member of the app object. And the "O" in "out" is capitalized. 

JavaScript is case sensitive. You must use the functions in the correct context and verbatim.

Here's the reference entry, Use It:

https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/#t=Acro12_MasterBook%2FJS_API_AcroJS%2Fapp_methods.htm%23TOC_setTimeOutbc-35&rhtocid=_6_1_8_6_1_34

 

 

 

 

Votes

Translate

Translate
Community Expert ,
Feb 20, 2020 Feb 20, 2020

Copy link to clipboard

Copied

 

app.setTimeOut ('app.alert("Hello World", 3)', 2000 );

 

 

The script input is a string. And "setTimeOut" is a member of the app object. And the "O" in "out" is capitalized. 

JavaScript is case sensitive. You must use the functions in the correct context and verbatim.

Here's the reference entry, Use It:

https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/#t=Acro12_MasterBook%2FJS_API_Acro...

 

 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
community guidelines
Explorer ,
Feb 20, 2020 Feb 20, 2020

Copy link to clipboard

Copied

I told you, you'd know at a glance!

 

Thanks, Thom.

Votes

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
community guidelines
Community Expert ,
Feb 20, 2020 Feb 20, 2020

Copy link to clipboard

Copied

Note that I updated my post with the correct syntax.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
community guidelines
Explorer ,
Feb 20, 2020 Feb 20, 2020

Copy link to clipboard

Copied

LATEST

I hear you on the caps; was aware, as my Subject Line indicates, but goofed in the script.

 

That Adobe SDK documentation is one of those many I read repeatedly.  Just goes to show the value of Forum, as a teaching tool [that even the best technical writing doesn't speak to the entire spectrum of user qualifications].

 

Note that I'm here attaching the corrected PDF, marked SOLVED, for benefit of other readers.

 

Votes

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
community guidelines