Copy link to clipboard
Copied
HI All,
I have a document, which I need to have the english words in a specific font. Otherwise I need to mark with any color. I tried with my script as show below, but it apply wrongly to all words except english character.
If you provide the solution for my coding or any other method, that would be helpful
var flag=0;
findmymagentatext();
function findmymagentatext()
{
var w = new Window ("dialog", "BEATS");
w.p1= w.add("panel", undefined, undefined, {borderStyle:"FONT"});
w.p1.add('statictext',undefined,"SELECT DESIRED COLOR");
w.p1.g = w.p1.add('group');
w.p1.g.orientation = 'column'
w.p1.g.alignChildren = "center";
var swatches=app.documents[0].swatches.everyItem().name;
var preset_list = w.p1.g.add ("dropdownlist", undefined, swatches);
w.orientation = "column";
w.add ("button", undefined, "OK");
w.add ("button", undefined, "Cancel");
var myResult = w.show()
if(myResult == 1){
if((preset_list.selection==null)){return;}
mychanges();
if(flag==0) {alert("No error found");}
}
else if (myResult== 2){
exit(0);
}
function mychanges(){
var mycolor=preset_list.selection.text;
var myarray=[];
app.findGrepPreferences = null; app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = '[a-zA-Z0-9.,?:;!]';
found = app.documents[0].findGrep();
for (i=0;i<found.length;i++) {
if((found.appliedFont.name!=="ITC Avant Garde Gothic Std\tBook") || (found.appliedFont.name!=="ITC Avant Garde Gothic Std\tDemi") || (found.appliedFont.name!=="ITC Avant Garde Gothic Std\tMedium")){
app.changeGrepPreferences.fillColor = mycolor;
found.changeGrep();
flag=1;
}
}
if(flag==1){
alert("Some Text area applied by wrong font, so it applied with color: "+mycolor);
return flag;
}
}
}
Advance Thanks,
K
Hi tpk,
Use && instead of ||
Thanks,
Prabu
Copy link to clipboard
Copied
Hi tpk,
Use && instead of ||
Thanks,
Prabu
Copy link to clipboard
Copied
No Ananth, I need to change any of this three fonts styles.. && wont work for this.. thanks
Copy link to clipboard
Copied
Ananth is right. Write out the Truth values for your conditions, and you'll see.
Copy link to clipboard
Copied
Sure let me check and let you know
Copy link to clipboard
Copied
Hi Jongware.. yes it is working..
But want to know how the && condition works.. it will work with all the three conditions get true, isnt it?
@prabhu: I will give you the correct answer