Kyrylics? app.doScript() issues.
Hello, dear community!
I have a trouble running my scripts, using another script for it. They all work, when I run them manually, but some of them do not even start to run, when i use my script. I suppose that the problem should be in kyrylics. I am not 100% sure, but all the scripts are pretty similar and only the strings in GREP find/change change.
The path is correct, the ecoding is UTF-8 (without BOM), the scripts without kyrylics run both ways and with it only manually. What could be a problem?
function runScriptRunner () {
// Define the scripts folder (relative to InDesign's Scripts folder)
var scriptsFolder = ""
// List of scripts to run (relative to the Scripts folder)
var scriptList = [
File(scriptsFolder + "1Character styles\\dont_change.jsx"),
//File(scriptsFolder + "1Character styles\\generate_character_styles.jsx"),
File(scriptsFolder + "2Extra spaces\\extra_spaces.jsx"),
File(scriptsFolder + "3Punctuation\\dashes.jsx"),
File(scriptsFolder + "3Punctuation\\quotes.jsx"),
File(scriptsFolder + "3Punctuation\\nested_quotes.jsx"),
File(scriptsFolder + "4Nonbreak spaces\\spaces_after.jsx"),
File(scriptsFolder + "4Nonbreak spaces\\spaces_before.jsx"),
File(scriptsFolder + "5Cornercases\\adpositions_and_conjunctions.jsx"),
File(scriptsFolder + "5Cornercases\\date_month.jsx")
];
// Iterate through the list of scripts and execute them
for (var i = 0; i < scriptList.length; i++) {
var currentScript = scriptList[i];
// Check if the script file exists
if (!currentScript.exists) {
alert('Script not found at "' + currentScript.fsName + '".');
continue;
}
else {
try {
alert("Running script: " + currentScript.fsName);
app.doScript(currentScript, ScriptLanguage.JAVASCRIPT, [], UndoModes.ENTIRE_SCRIPT); // Execute the script inside InDesign
} catch (error) {
alert("Error running script: " + currentScript.fsName + "\n" + error);
}
}
}
alert("All scripts executed.");
}
// Run the script runner
runScriptRunner();Here is an code example which does not run:
function performGREPFindChange(findWhat, changeTo) {
// Clear previous GREP find/change preferences
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences = NothingEnum.nothing;
// Set new GREP find/change settings
app.findGrepPreferences.findWhat = findWhat;
app.changeGrepPreferences.changeTo = changeTo;
try {
// Perform the Find/Change operation
app.activeDocument.changeGrep();
} catch (e) {
alert("Error: " + e.message);
}
}
performGREPFindChange('(\\d+)\\s*(січня|лютого|березня|квітня|травня|червня|липня|серпня|вересня|жовтня|листопада|грудня)', '$1~S$2');