validate paragraph style names based on list
I am attempting to modify a script I found that checks if style names in a supplied array exist in the active document. I wish to turn this around and report the styles in the active document that are not in the supplied list.
I suspect the second for loop in the script below is not doing what I want it to do. The notFoundStyles array lists all the styles in the list as well as the one style not in the list.
Here is my current script:
var pStyles = app.activeDocument.paragraphStyles.everyItem().name
var foundStyles = Array();
var notFoundStyles = Array();
var styles = Array();
var styles = {
CompanyName: "CompanyName",
Footnotes: "Footnotes",
Head_Author: "Head_Author",
Head_Chapter: "Head_Chapter",
Head_Title: "Head_Title",
TOCList: "TOCList",
Text_Body: "Text_Body",
Text_Body_InitialCap: "Text_Body_InitialCap",
Text_Copyright: "Text_Copyright",
poem: "poem"
}
for (var key in styles ) {
if (pStyles.join().indexOf(styles[key]) != -1){
foundStyles.push (styles[key]);
}
}
for (var myP in pStyles) {
if ((pStyles[myP].indexOf) ((styles[key])) == -1){
notFoundStyles.push (pStyles[myP]);
}
}
{alert('Not Found: ' + notFoundStyles + '\nFound: ' + foundStyles)}
