Copy link to clipboard
Copied
What I'm thinking of is determining if the last row is empty.
If it's empty, set it to footer.
If it's not empty, add one empty row at the end and set the empty row to footer.
When you don't expand the text box, it says “empty”. (This is actually wrong.)
When you expand the box, it says “not empty” again.
I'm a little confused about functions, methods, and objects.
Also, if you take out the Break, it becomes a dead loop?
How do I get the code after it to run?
Please guide me.
Thank you very much.
See attachment for sample.
“alter” is used for testing. Can be deleted
var cell = app.activeDocument.selection[0].parent;
var myTable = cell.parent;
var myFooterRow = myTable.rows[-1];
dupeLastRow(myTable);
function dupeLastRow(p){
var isLastRowEmpty = true;
for (var j = 0; j < myFooterRow.cells.length; j++) {
if (myFooterRow.cells[j].contents !== "") {
isLastRowEmpty = false;
alert("No-empty");
break;
}
else{
isLastRowEmpty = true;
alert("empty");
break;
}
}
if(isLastRowEmpty = false){
myTable.rows.add(LocationOptions.AFTER, myTable.rows[-1]);
myFooterRow = myTable.rows[-1];
}
else{
isLastRowEmpty = true;
myFooterRow = myTable.rows[-1];
}
}
Copy link to clipboard
Copied
Invisible cells - cells that are in the overset text - your 1st table in the screenshot - or cells that are completely overset - no text inside, just red dot - do not have any contents.
So your if should be:
if (myFooterRow.cells[j].texts[0].contents !== "") {
Copy link to clipboard
Copied
Thnak you.
The judgment seems to be right, for some reason the last "if else" doesn't run
I've deleted break.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Oh, I think so.isLastRowEmpty = falseShould be isLastRowEmpty == false
By @dublove
Yes, in JS even in the if, one "=" is "assignment" so you need to use double "==" for comparison.
Copy link to clipboard
Copied
> Invisible cells - cells that are in the overset text - or cells that are completely overset - no text inside, just red dot - do not have any contents.
That's not true: if a cell with content is in an invisible row, its content is returned as if it were visible.
Because InDesign pushes everything out of a cell when it's overset, it's difficult to tell the difference between a visible overset cell and a cell in an overset row (an invisible row).
One way of making sure that overset rows won't bite you is to expose a table when one or more rows are in overset text. The test is to check how many lines the table's parent paragraph has:
if (myTable.storyOffset.paragraphs[0].lines.length > 1) {
// expose the table by making the text frame taller
}
Copy link to clipboard
Copied
I don't really understand it.
Haven't come across an example to test.
Hopefully I'll never run into this mine.
It's too hard to try to actively create a bug.
Is this the one below? This one recognizes a “true empty row”.
Anyone have a bug to offer?