Two scripts for easier threading/unthreading text
so.. i'we got this project that consists mostly of fixing tons of threaded text, eventualy for exporting it to rtf.
i'we wrote this two scripts the first one for beaking the thread at the beginning of the current frame
wich is working excelent.
#target "InDesign"
#targetengine "session"
//var contextMenu = app.menus.itemByName("$ID/RtMouseText");
//contextMenu.menuItems.add(breakframe(),LocationOptions.AFTER,"Break Frame");
var myBreakFameScriptAction=app.scriptMenuActions.add("Break Frame");
var myEventListener=myBreakFameScriptAction.eventListeners.add("onInvoke", function ()
{
app.doScript(function(){
try{
myFrame=app.activeDocument.selection[0].parentTextFrames[0];
myChar=myFrame.characters[0];
myText=myChar.parentStory.characters.itemByRange (myChar.index, app.selection[0].parentStory.characters[-1].index);
myFrame.previousTextFrame=null;
myText.move(LocationOptions.after,myFrame.insertionPoints[0]);
}
catch (myerror){alert("Invalid Frame. Mabye tabel?");}
},undefined,undefined,UndoModes.entireScript,'Break Frame');
});
try {
var myBreakScriptMenuItem=app.menus.item("$ID/RtMouseText").menuItems.item(
"Break Frame");
myBreakScriptMenuItem.title;
}
catch (myError){
var myBreakScriptMenuItem = app.menus.item("$ID/RtMouseText").menuItems.add(myBreakFameScriptAction);
}
the second one is for threading text in the selected textframes, like the "linkster" tool in Quark 9.2 but it works a wierd, instead of linking them in the selected order it links them in .. don't really know what order (I understand that it should work in CS6, but i need it in CS5). Can someone give me a idee how can i fix it?
app.doScript('linkster(app.activeDocument.selection)',undefined,undefined,UndoModes.entireScript,'Linkster');
function linkster(mySelection){
try {
if ((mySelection.length>0)& (testConstr (mySelection)))
{
for (var i=0; i<mySelection.length; i++){
mySelection.insertionPoints.lastItem().contents=SpecialCharacters.FRAME_BREAK;
if (i>0){
if (mySelection.previousTextFrame==null)
mySelection.previousTextFrame=mySelection[i-1];
}
}
}
}catch (e) {alert (e.message + "\r(line " + e.line + ")\rInvalid Selection")};
}
function testConstr(mySelect){
for (var i=0; i<mySelect.length; i++){
if (mySelect.constructor.name!="TextFrame") return false;
}
return true;
}