I have another, hopefully easy to solve, problem.
I have generated a script, using the wonderful ChainGREP script by Gregor Fellenz.
https://www.indesignblog.com/2017/02/gr ... atisieren/ (sorry, not in english)
The ChainGREP script allows searches saved in InDesign to be chained and processed as a script saved. The GREP search includes the removal of "Discretionary Hyphen".
The script works fine as a local script in InDesign. However, when I include the script in the InDesign configurator, it does not work. There is no error message in the switch log, the script is "executed successfully". However, the Find+Replace function has not been executed in the result, all "Discretionary Hyphen" are still there.
Does anyone have an idea what this could be due to?
Many thanks and best regards,
Peter
Code: Select all
//This script was auto generated by chainGREP.jsx
//chainGREP.jsx is provided by Gregor Fellenz https://www.publishingx.de/
//Download at https://www.publishingx.de/download/chain-grep
main();
function main() {
if (app.layoutWindows.length == 0) return;
var changeObject = app.documents[0];
if (changeObject.hasOwnProperty('characters') && changeObject.characters.length == 0) return;
var doc = app.documents[0];
var style;
var scriptVersion = app.scriptPreferences.version;
app.scriptPreferences.version = 17.0;
var options = app.findChangeGrepOptions.properties;
app.findGrepPreferences = NothingEnum.NOTHING;
app.changeGrepPreferences = NothingEnum.NOTHING;
// Query [[PxC_bedingten Trennstrich löschen]] -- If you delete this comment you break the update function
try {
app.findChangeGrepOptions.properties = ({includeFootnotes:true, kanaSensitive:true, widthSensitive:true});
app.findGrepPreferences.properties = ({findWhat:"~-"});
app.changeGrepPreferences.properties = ({});
changeObject.changeGrep();
} catch (e) {alert(e + ' at line ' + e.line)}
app.findChangeGrepOptions.properties = options;
app.findGrepPreferences = NothingEnum.NOTHING;
app.changeGrepPreferences = NothingEnum.NOTHING;
app.scriptPreferences.version = scriptVersion;
};
function getStyleByString(docOrGroup, string, property) {
if (string == '[No character style]') return docOrGroup[property][0];
if (string == '[No paragraph style]') return docOrGroup[property][0];
if (string == 'NormalParagraphStyle') return docOrGroup[property][1];
stringResult = string.match (/^(.*?[^\\]):(.*)$/);
var styleName = (stringResult) ? stringResult[1] : string;
styleName = styleName.replace (/\\:/g, ':');
remainingString = (stringResult) ? stringResult[2] : '';
var newProperty = (stringResult) ? property.replace(/s$/, '') + 'Groups' : property;
var styleOrGroup = docOrGroup[newProperty].itemByName(styleName);
if (remainingString.length > 0 && styleOrGroup.isValid) styleOrGroup = getStyleByString (styleOrGroup, remainingString, property);
return styleOrGroup;
};