Skip to main content
michaelw38411182
Participant
November 17, 2016
Question

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

  • November 17, 2016
  • 4 replies
  • 476 views

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?

This topic has been closed for replies.

4 replies

Inspiring
November 18, 2016

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

Give your function a different name.

Bernd Alheit
Community Expert
Community Expert
November 18, 2016

No problem with this function.

Inspiring
November 18, 2016

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

try67
Community Expert
Community Expert
November 17, 2016

Works fine for me...