Skip to main content
Inspiring
October 13, 2009
Question

Link update in InDesign CS4 JS

  • October 13, 2009
  • 1 reply
  • 1610 views

Hi, I need some help. This loop use to work, but know it's giving me an error, and when I added the alert I see that it's giving me only first letter of the file's name. Could you help me to find out what happened.


for (var a =0; a<app.activeDocument.rectangles.length-1; a++){

myArt = app.activeDocument.rectangles.graphics[0];
myArtName = myArt.itemLink.name[0];
alert (myArtName);
myArt.itemLink.update (myArtName);
}

Thank you very much.

Yulia

This topic has been closed for replies.

1 reply

ramkumar_vp
Inspiring
October 13, 2009

Hi Yulia,


Wrong: myArtName = myArt.itemLink.name[0];


Correct : myArtName = myArt.itemLink.name;


itemLink.name is a string, if you get the String[0] it returns the first character.


I think now you got it.


Regards,

Ramkumar

Jongware
Community Expert
Community Expert
October 14, 2009

(w/o actually trying!) -- the last variant might work if you change it to

if (myArt.itemLink.linkStatus == LinkStatus.LINK_OUT_OF_DATE)

1st: To assign, use single equate; to compare use double equates

2nd: Use full names for enumerations -- including its type.

And I now see another tiny but potentially irritating bug

for (var a =0; a<app.activeDocument.rectangles.length-1; a++)

will process all but the very last rectangle. Don't use '-1' in combination with '<' (think about what this does).