for loop bug?

Discussion of actual or possible Photoshop Scripting Bugs, Anomalies and Documentation Errors

Moderators: Tom, Kukurykus

Mike Hale

for loop bug?

Post by Mike Hale »

xbytor wrote:docRef.height.value is the recommended way of getting the value out of a UnitValue object.

Perhaps so, but docRef.height.value still loops to 14 when it should stop at 13.

docRef.height.value displays as 14 but when o=14 in the loop o<docRef.height.value test true and the loop continues when it should have stopped.

Mike
xbytor

for loop bug?

Post by xbytor »

It's even weirder.
This log is from a jsh session where doc is a 3x14 px image.

Code: Select all2008-06-03T18:54:47$ doc.height.value == 14
2008-06-03T18:54:47$ false
2008-06-03T18:54:59$ doc.height.value
2008-06-03T18:54:59$ 14
2008-06-03T18:55:15$ doc.height.value == 14.0
2008-06-03T18:55:15$ false
2008-06-03T18:55:33$ Number(doc.height.value) == 14
2008-06-03T18:55:33$ true
2008-06-03T18:55:46$ doc.height.value < 14
2008-06-03T18:55:46$ false
2008-06-03T18:55:55$ doc.height.value > 14
2008-06-03T18:55:55$ true
2008-06-03T18:56:48$ Math.floor(doc.height.value) == 14
2008-06-03T18:56:48$ true

With large values (eg. doc.height = 360px), this does not happen.

It's something I can't really explain.

-X