1 Reply Latest reply on Jun 16, 2012 5:21 AM by Dirk Becker

    Script is... too fast?

    Jump_Over Level 5


      Is that possible, that script do things faster then InDesign can react, so some codes return false results?

      For example this situation:

      There is a 1 row 4 columns table with contents. All of those cell's default width is equal ( = table.width/4).

      So I want to fit those width to the contents and run this...


      table.cells.everyItem().width = 5;

              for (var u = 0; u < table.cells.length ; u++)


                  while (table.cells[u].overflows){






      It works fine as a separate code.

      But as a part of longer one (this is a function called from main body)

      goes to recursive job: cell is growing, cause cells[u].overflows keeps value = true unless cells width gone to "tousend of points".


      Is cells[u].overflows value (true or false) depend on InDesign display abilities?



      edited later...


      If I replace while conditions to:


      for (var u = 0; u < table.cells.length ; u++)


                  while (table.cells[u].contents !== table.cells[u].paragraphs[0].contents)




      it works fine in both ways.



        • 1. Re: Script is... too fast?
          Dirk Becker Level 4

          Composition (text reflow) is deferred until needed, e.g. by drawing. Usually the script glue code does it itself e.g. when you check for overflows, but some occasions are still missing, such as the late addition of tables.

          To solve your problem you can force composition with the recompose() method of the document or the text story.