Skip to main content
Jump_Over
Legend
June 16, 2012
Question

Script is... too fast?

  • June 16, 2012
  • 1 reply
  • 968 views

Hi,

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.overflows){

            table.cells.width++;

            }

        }

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

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.overflows keeps value = true unless cells width gone to "tousend of points".

Is cells.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.contents !== table.cells.paragraphs[0].contents)

            table.cells.width++;

         }

it works fine in both ways.

thx

This topic has been closed for replies.

1 reply

Legend
June 16, 2012

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.

Dirk