Skip navigation
Currently Being Moderated

Script is... too fast?

Jun 16, 2012 5:21 AM

Tags: #cs5 #scripting

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

            table.cells[u].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[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)

            table.cells[u].width++;

         }

 

it works fine in both ways.

 

thx

 
Replies
  • Currently Being Moderated
    Jun 16, 2012 5:21 AM   in reply to Jump_Over

    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

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points