//*==========================================================================
InDesign ExtendScript
NAME: InScript
VERSION: 1.0
AUTHOR: Michail Silin
DATE : 2.08.2005
DESCRIPTION: Run Scripts in {Script@ and @} in text frames.
SUPPORT:
E-MAIL: glutton@mail.ru
============================================================================ */
startString="Script@"
EndString="@"
with (app) {
if (documents.length < 1) {
alert("No open documents");
exit();
}
myDoc = activeDocument;
for (tf = 0; tf < myDoc.allPageItems.length; tf++) {
var mylabel = myDoc.allPageItems[tf].label;
var myRegExp = new RegExp(startString+"([^\u0000,"+EndString+"]+)"+EndString, "gim");
arrHeads = mylabel.match(myRegExp);
if (arrHeads!=null) {
for (j = 0; j < arrHeads.length; j++) {
var ScriptText = arrHeads[j].substr(startString.length,arrHeads[j].length-startString.length-EndString.length);
ScriptText=ScriptText.replace("InS","activeDocument.allPageItems[tf].contents");
ScriptText=ScriptText.replace('[“,”,«,»]','"');
eval(ScriptText);
if(myDoc.allPageItems[tf].constructor.name!="TextFrame")
{
}else{
var MaTF=myDoc.textFrames.itemByID(myDoc.allPageItems[tf].id);
var myPara = MaTF.lines[0];
var StartIP = myPara.insertionPoints.item(0);
var EndIP = myPara.insertionPoints.item(myPara.insertionPoints.length-2);
MaTF.geometricBounds[3] = EndIP.horizontalOffset - StartIP.horizontalOffset+MaTF.geometricBounds[1];
}
}
}
}
}