Article View: adobe.scripting.indesign
Article #762Re: it can not search the text with Grep, what's wronge with my code?
From: robin521
Date: Mon, 02 Mar 2009 12:03
Date: Mon, 02 Mar 2009 12:03
86 lines
2889 bytes
2889 bytes
Hi Peter,
how can i get current fonts style and pointsize when i search it by grep, i mean, i need to find the word by grep but when this fonts is different style i need to change it and different pointsize also.
main();
function main(){
if(app.documents.length != 0){
if(app.activeDocument.pageItems.length != 0){
}
else{
alert("Document contains no page items.");
}
}
else{
alert("Please open a document and try again.");
}
}
var MyFontList=new Array;
MyFontList=app.fonts.everyItem().name;
var MyDialog=app.dialogs.add({name:"change your heart"});
with(MyDialog){
with(dialogColumns.add()){
with(borderPanels.add()){
staticTexts.add({staticLabel:"target:"});
}
with(dialogColumns.add()){
var myMenu=dropdowns.add();
myMenu.stringList=MyFontList;
myMenu.selectedIndex=0;
}
}
var myResult=MyDialog.show();
if(myResult== true )
{
var changeWord=myMenu.selectedIndex;
var changeTo=app.fonts[changeWord].name;
alert("you cange the font to"+changeTo)
FindGrep();
}
else{
alert ("you are fault")
}
MyDialog.destroy();
}
function FindGrep(){
//Clear the find/change preferences.
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences = NothingEnum.nothing;
//Set the find options.
app.findChangeGrepOptions.includeFootnotes = false;
app.findChangeGrepOptions.includeHiddenLayers = false;
app.findChangeGrepOptions.includeLockedLayersForFind = false;
app.findChangeGrepOptions.includeLockedStoriesForFind = false;
app.findChangeGrepOptions.includeMasterPages = false;
//find
app.findGrepPreferences.findWhat = "[^A-Za-z0-9/.-]+";
app.changeGrepPreferences.appliedFont=changeTo;
var myFoundItem= app.findGrep ();
if(app.changeGrepPreferences.pointSize=app.findGrepPreferences.pointSize){
var number=0;
number=app.findGrepPreferences.pointSize
number=1.3*number;
number=app.changeGrepPreferences.pointSize;
}
app.changeGrepPreferences.underline = true;
app.documents.item(0).changeGrep();
//Clear the find/change preferences after the search.
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences = NothingEnum.nothing;
}
Technical Details
Message-ID:
<59b7f00d.9@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!newshub.sdsu.edu!webcrossingReferences:
<59b7f00d.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,72cfdd46072287ca X-Google-Attributes: gidf939a,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: robin521@adobeforums.com Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.scripting.indesign Subject: Re: it can not search the text with Grep, what's wronge with my code? Message-ID: <59b7f00d.9@webcrossing.la2eafNXanI> Date: Mon, 2 Mar 2009 04:03:54 -0800 References: <59b7f00d.-1@webcrossing.la2eafNXanI> Lines: 88 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit