1 Reply Latest reply on Mar 20, 2009 1:26 PM by (Robert_Tkaczyk)

    Need help to debug simple javascript in CS3

    scottjwood Level 1
      Here's what I'm trying to accomplish:
      I have 25 separate InDesign documents that have been populated via EasyCatalog and a data extract. There is one part of the content I need to target, which is a bullet list. The way the easy catalog brings in the bullets is via a table, each list is in it's own table, each bullet on it's own row (with a bullet character preceding the text in the row). Problem being that the client wants the bullets formatted like this (Bullet1 | Bullet2 | Bullet3) Basically a single line of copy that wraps in a text box, not a bullet list.

      I need to convert each table in the document into text, then take out the bullet character and separate each row with the "|" character.

      Here's the script that I finally got to run without errors, but now it just runs and runs and runs and doesn't do anything. It locks up indesign if I run it through the scripts panel, but running it through ExtentScript, I can stop it and continue using ID.
      --------------------------------------------------------------------------

      var myDoc = app.activeDocument;

      for(i = myDoc.stories.length - 1; i >= 0; i)
      for(j = myDoc.stories[i].tables.length - 1; j >= 0; j) { var myTable = myDoc.stories[i].tables[j]; myTable.convertToText( ",", "|"); }

      --------------------------------------------------------------------------

      I'm not very savvy with scripting, I've worked on this for many hours trying to figure it out. I'm hoping someone can just look at this and be like "you dumb@$$, just change xy & z and it'll work".

      So anyone that'll consider looking at this, and see what I'm doing wrong, the help will be much appreciated. And you'd totally be free to heckle me for not being able to figure it out! :)
        • 1. Re: Need help to debug simple javascript in CS3
          Level 1
          you need to decrease "i" and "j"

          "i--" and "j--"


          for (var=startvalue;var<=endvalue;var=var+increment)
          {
          code to be executed
          }

          so:

          --------------------------------------------------------------------------

          var myDoc = app.activeDocument;

          for(i = myDoc.stories.length - 1; i >= 0; i--)
          for(j = myDoc.stories[i].tables.length - 1; j >= 0; j--) { var myTable = myDoc.stories[i].tables[j]; myTable.convertToText( ",", "|"); }

          --------------------------------------------------------------------------

          robin

          --
          www.adobescripts.com