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

Delay in Message

New Here ,
Nov 04, 2024 Nov 04, 2024

I am looking to put a delay in a message but the following does not work for me

 

app.setTimeOut(app.alert("Hello"), 5000);

 

Any ideas on what i'm doing wrong.

 

Thanks,

 

Alan

TOPICS
Acrobat SDK and JavaScript , Windows
391
Translate
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 ,
Nov 04, 2024 Nov 04, 2024

The code to execute must be a string:

 

app.setTimeOut("app.alert(\"Hello\")", 5000);

Translate
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
New Here ,
Nov 04, 2024 Nov 04, 2024

Hi try67,

 

thank you that worked perfectly.

 

is it possible to apply the principle to a function

 

Thanks,

 

Alan

Translate
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
New Here ,
Nov 04, 2024 Nov 04, 2024

Hi,

 

I think i have resolved the issue.

 

Regards,

 

Alan

Translate
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
New Here ,
Nov 04, 2024 Nov 04, 2024

Unfortunately what i thought was gonna work didnt and for some reason i cant get a delay for 60 seconds the max it 9.

 

Is there an issue with 60 seconds

Translate
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 ,
Nov 04, 2024 Nov 04, 2024

No, should work fine. Are you aware the delay is in ms, so 5000 is 5 seconds?

Translate
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
New Here ,
Nov 04, 2024 Nov 04, 2024

Hi try67,

 

Yep I'm.aware of the Ms I set it to 9000 and works but when I increase to 60000 nothing happens.

 

app.setTimeOut("app.alert(\"Hello\")", 5000);

Works perfect until I try to go past 10 seconds.

 

 

Translate
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 ,
Nov 05, 2024 Nov 05, 2024

Try this, Instead of using a single timeout, use an interval of 5 seconds and a counter. 

 

global.nIntCount = 0;

global.nInterval  = app.setInterval("if(++global.nIntCount >= 12){app.clearInterval(global.nInterval);app.alert(\"Hello\");}", 5000);

 

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

Translate
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
New Here ,
Nov 05, 2024 Nov 05, 2024

Thank you that worked perfectly

Translate
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 ,
Nov 05, 2024 Nov 05, 2024
LATEST

- You need to save the return value of the setTimeOut method to a variable, even if you don't use it later on.

- While the alert window is open the counter does not progress, as that window is modal and blocking further execution of code.

Translate
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