I am rather new to InDesign scripting.
I have made a script that gets a table and, cell by cell, goes into the text, sees if it overflows and if so decreases the HorizontalScale by 1%, as many times as necessary to fit the text so removing any overset.
It works perfectly ONLY IF there is an alert that stops temporarily the execution.
If I let it go without it, it is not working.
This is my script
function processTable(table) {
for (i=0; i<table.cells.length; i++)
{
horscale = 100;
while ((table.cells[i].overflows) && (horscale >=50)) {
//alert ("newTextSize: "+horscale); //if I leave this alert it works perfectly, if I take it out it doesn't
table.cells[i].texts[0].horizontalScale = parseFloat(horscale);
horscale = horscale - 1;
}
}
}
If I let it go without the alert (like above it is commented) the horscale gets always to 50, showing that it cannot check if text is overflowing in all steps.
Anyone can help? I would just need to "pause" an instant, I guess, or redraw or refresh or anything that lets InDesign re-check if the text is still overflowing during that iteration.
Thanks in advance