• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Dead Loop? How do I jump out and why do I get two results for the same text box?

Advisor ,
Jan 01, 2025 Jan 01, 2025

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];
	}
	}

 

 

 

 Unexpanded.jpgExpand fully.jpg

TOPICS
Bug , Feature request , How to , Scripting

Views

159

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 01, 2025 Jan 01, 2025

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 !== "") {

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jan 01, 2025 Jan 01, 2025

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jan 01, 2025 Jan 01, 2025

Copy link to clipboard

Copied

Oh, I think so.
isLastRowEmpty = false
Should be isLastRowEmpty == false

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 01, 2025 Jan 01, 2025

Copy link to clipboard

Copied

quote
Oh, I think so.
isLastRowEmpty = false
Should be isLastRowEmpty == false

By @dublove

 

Yes, in JS even in the if, one "=" is "assignment" so you need to use double "==" for comparison. 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 02, 2025 Jan 02, 2025

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
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jan 02, 2025 Jan 02, 2025

Copy link to clipboard

Copied

LATEST

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?

069.jpg

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines