3 Replies Latest reply on Jun 14, 2013 4:21 PM by try67

    Forcibly terminating Acrobat Script with "exitapp"

    skappy1974

      I have an Adobe XI javascript that checks several input parameters before executing.  If any of these parameters do not meet specified criteria, then I print out a message and abort the script.  I am using the command "exitapp" to abort, and this seems to work.  My question is: is "exitpp" a legitimate javascript command?  I cannot find this command in any of the javascript references.  Yet it appears to work fine for me on 2 pc's -- one running Adobe Acrobat XI Pro and the other running Adobe Acrobat XI reader..  I'm concerned that the script may fail when I distribute it to others if this is not a legitimate command.

        • 1. Re: Forcibly terminating Acrobat Script with "exitapp"
          try67 MVP & Adobe Community Professional

          No, this is not a valid JS command. What's happening is probably that the script throws an error (which you can see in the console), and exits. This is not a good way of doing it.

          If your code is located in a function, you can use the return command to exit it. If it's not, you should place it in one...

          • 2. Re: Forcibly terminating Acrobat Script with "exitapp"
            skappy1974 Level 1

            Gilad D, Thanks for your quick and helpful reply.  As a javascript newbie I was not aware of how helpful the console can be.  Thanks for pointing this out.  It turns out that I was trying to abort my script from inside a function.  After putting my entire script inside a function as you suggested, the return command just brings me back to the main program and does not abort.  What I did (and I'm not sure it's the most efficient way to do it) was to set a flag inside the inner function with a value of "0" if I do not want to abort and a value of "1" if I do want to abort.  Then after exiting the inner function, if this flag is a "1", then I use a return command to exit the outer (i.e., the main) function.  Confusing but it works fine with no console errors.  Thanks again.

            • 3. Re: Forcibly terminating Acrobat Script with "exitapp"
              try67 MVP & Adobe Community Professional

              That's a good way of doing it. There's no command in JS to just stop the execution of the script entirely.