repeat loop vs whose statement in InDesign

Ok so I have a working script using a repeat loop that goes in a document and changes ever border of cells that have a bottom edge stroke weight to 0 and puts a red stroke of 1 pt instead. That works, but it is really long because the script as to go through every cell of every table of the document. I’ve tried to use cell whose bottom edge stroke weight is 0 to do the same thing but it just puts the red stroke on every bottom edge stroke instead of using my whose statement.

Here’s the script that works, I’m also doing all edge of the cell


tell application “Adobe InDesign CC”
set myDocument to active document

tell myDocument
	try
		set mySwatch to (make color with properties {model:process, space:RGB, color value:{255.0, 0.0, 0.0}, name:"ROUGE"})
	end try
	set mytableStroke to color "ROUGE"
	set allTables to tables of text frames of myDocument
	repeat with i from 1 to count of allTables
		tell item i of allTables
			repeat with j from (count of cells) to 1 by -1
				try
					set mybottomstroke to (bottom edge stroke weight of cell j)
					set myLeftStroke to (left edge stroke weight of cell j)
					set myRightStroke to (right edge stroke weight of cell j)
					set myTopStroke to (top edge stroke weight of cell j)
					if mybottomstroke is 0 then
						set properties of cell j to {bottom edge stroke weight:"1 pt", bottom edge stroke color:mytableStroke, bottom edge stroke tint:100}
					end if
					if myLeftStroke is 0 then
						set properties of cell j to {left edge stroke weight:"1 pt", left edge stroke color:mytableStroke, left edge stroke tint:100}
					end if
					if myRightStroke is 0 then
						set properties of cell j to {right edge stroke weight:"1 pt", right edge stroke color:mytableStroke, right edge stroke tint:100}
					end if
					if myTopStroke is 0 then
						set properties of cell j to {top edge stroke weight:"1 pt", top edge stroke color:mytableStroke, top edge stroke tint:100}
					end if
				end try
			end repeat
		end tell
	end repeat
end tell
activate
beep

end tell


Now here’s the script that doesn’t work as intended:


tell application “Adobe InDesign CC”
set myDocument to active document

tell myDocument
	try
		set mySwatch to (make color with properties {model:process, space:RGB, color value:{255.0, 0.0, 0.0}, name:"ROUGE"})
	end try
	set mytableStroke to color "ROUGE"
	tell (cells whose bottom edge stroke weight is 0) of tables of text frames of myDocument to set properties to {bottom edge stroke weight:"1 pt", bottom edge stroke color:mytableStroke, bottom edge stroke tint:100}
end tell
activate
beep

end tell


Any hint would be great!
TIA
Jeff

Hi,

the whose syntax is supposed to be whose
so try


.
tell (cells of tables of text frames of myDocument whose bottom edge stroke weight is 0)  to set properties to {bottom edge stroke weight:"1 pt", bottom edge stroke color:mytableStroke, bottom edge stroke tint:100}
.

Hi Stephan,

unfortunately I get the same result, being every bottom stroke gets RED, not just the one with a 0 weight.

Jeff

Hi. Cell-level operations in prior versions of CS have been somewhat buggy and require greater precision than their standard repeat loop counterparts; i.e., 0.0, rather than 0.

tell application "Adobe InDesign CS3"'s document 1
		set imprecise to ((stories's tables)'s cells whose its bottom edge stroke weight = 0)
	set exact to ((stories's tables)'s cells whose its bottom edge stroke weight = 0.0)
end tell
{imprecise, return, return, return, exact}

Hi Marc,

I get all impricese cells when I run your script. Now the problem I have is even using your way of calling those cells, which is pretty cool by the way, when I want to affect those cells, I either get en error message of I set the cells to a variable as in your exemple, or I get a all my bottom edge stroke RED, which is what I was getting with my code in the first place.

Here’s what I’ve tried,
this gives me a RED stroke on every cell in the document
tell ((stories’s tables)'s cells whose its bottom edge stroke weight = 0) to set properties to {bottom edge stroke weight:“1 pt”, bottom edge stroke color:mytableStroke, bottom edge stroke tint:100}

And this gives me en error
set myCells to ((stories’s tables)'s cells whose its bottom edge stroke weight = 0)
tell myCells to set properties to {bottom edge stroke weight:“1 pt”, bottom edge stroke color:mytableStroke, bottom edge stroke tint:100}

So how do I go about affecting only the cell I want?

TIA
Jeff

ok, I figured it out. You where right, it needs to be 0.0, so…

this works

		tell ((stories's tables)'s cells whose its bottom edge stroke weight = 0.0) to set properties to {bottom edge stroke weight:"1 pt", bottom edge stroke color:mytableStroke, bottom edge stroke tint:100}

Thanks!
Now I just need to figure out how to do the reverse in word!