2 Replies Latest reply on Oct 29, 2011 2:14 PM by Roy Marshall

    [JS][CS5] Processing files in the background

    Roy Marshall Level 1

      Hi.

       

      I have made a small procees that a user fills in an online form, =>mySql Database => InDesign =>PDF File.

       

      The way I have this working in the background is to have a script taking over the whole of ID, constantly checking for new entries in the mySql database, and processing the row. I have the whole script in a while loop looking at the contents of a text file I have in a certain folder. To break the loop I change the contents of this text file from 'run' to 'stop'.

       

      Tesing this works fine, but the script seems to stop after a few minutes of its own accord. Nothing crashes, no errors. Is there a more elegant way to have InDesign monitor this database? Preferably without taking over ID?

       

      Just thought Id ask.

       

      Cheers

       

      Roy

        • 1. Re: [JS][CS5] Processing files in the background
          John Hawkinson Level 5

          Yeah, this doesn't sound like a good architecture.

          Your use of the word "process" suggests you may not have a lot of familarity with the way your operating system (which one?) handles multiple simultaneous programs. You might want to read up on that.

           

          i would create a sepeate Process (entirely unrelated to InDesign) that did the database querying and could communicate to the InDesign script via a mechanism that's very small and quick (such as the existence of a "flag" file to indicate there was work to do),.

           

          Then, you can add your  script as an Idle event handler (in CS5 and later, only, unless you have and are ok with depending on APID Toolkit), and every time it gets an idle event, check to see if the flag file (or whatever) exists.

           

          No idea why your script stops on its own accord. You should:

          1. Break your script down to the smallest possible case that reproduces the failure

          2. Wrap it in try/catch and report errors via alert() or $.writeln(). Some persistent scripts seem to escape from the normal error handling conditions (not sure if thisis a bug)

          3. Post your minimal version of the script.

          1 person found this helpful
          • 2. Re: [JS][CS5] Processing files in the background
            Roy Marshall Level 1

            Hi John.

             

            Thanks for the reply. It turns out that when I active the script using a Configurator plugin, it times out after 5 mins. Running from the scripts panel doesn't time out.

             

            I will look at the suggestions around the process, as it does bug me InDesign is using all the system resourses while effectivly doing nothing.

            Thanks again

             

            Roy