Textframe threading script in Indesign
Hi,
I have 3 textframes in InDesign. I am trying to thread them using a script. Currently I am working on only one page but in future there might me multiple pages.
I have written a script to thread the textframe, however, I am not able to understand how it is working.
Here is the code:
var myDoc = app.documents[0];
var myFrames = myDoc.textFrames;
for(i=1;i<myFrames.length;i++){
myFrames[i].previousTextFrame = myFrames[i-1];
}I took this code from somewhere, I mean the previousTextFrame line and fail to understand how it is working. Ideally should'nt it be the the next frame ?
Another question is that when I put some data in the text frame before threading, why is it starting from the last textframe.
Here is the code which I wrote to put data in the textframe without threading:
var myDoc = app.documents[0];
var myFrames = myDoc.textFrames;
//alert(myFrames.length);
for(i=0;i<myFrames.length;i++){
myFrames[i].contents = "Data: " + i;
}
I also tried reversing then the code is not working at all. Here is the reversed code:
var myDoc = app.documents[0];
var myFrames = myDoc.textFrames;
for(i=myFrames.length; i> 0;i--){
myFrames[i].contents = "Data: " + i;
}
Can anyone shed some light on this. Thanks.
