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

In JavaScript Loop Construct, Evaluating Conditional Before Iteration Throws "GeneralError: Operation failed"

New Here ,
Nov 17, 2016 Nov 17, 2016

Here is an example in a function entered in the console in Acrobat Pro 11.0.18:

function loop() { console.println("\nBegin"); var i; for (i=0;i<5;i++) { console.println(i); }}

This produces the following output when executed in the console:

loop()

Begin

0

GeneralError: Operation failed.

Root.(null):1:Console undefined:Exec

script terminated

undefined

The loop appears to execute once, but then throws an error when evaluating the conditional before the second iteration. I had similar results when casting the loop as a while statement, except that it failed before executing the loop even once, presumably because it had to evaluate the condition before the first iteration.

This issue also arose during batch operation.

Any insight?

TOPICS
Acrobat SDK and JavaScript
423
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 17, 2016 Nov 17, 2016

Works fine for me...

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
LEGEND ,
Nov 17, 2016 Nov 17, 2016

You might try including  a "return" to terminate your function.

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 18, 2016 Nov 18, 2016

No problem with this function.

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
LEGEND ,
Nov 18, 2016 Nov 18, 2016
LATEST

Do you have a form open or created a JavaScript object eith a name of "loop".

Give your function a different name.

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