• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Kyrylics? app.doScript() issues.

Community Beginner ,
Jan 27, 2025 Jan 27, 2025

Copy link to clipboard

Copied

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');
TOPICS
Bug , Scripting

Views

53

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Jan 27, 2025 Jan 27, 2025

Oh I've just got it... It seems the problem must be in the loops where I use the same named variable , and it's JS... Thanks! I've been trying to fix it for 5 days... Like always so obvious solve when you realize it...  
So in some scripts your i in loop becomes bigger than the number of elements in list and it just ends. Be careful with variables namings! 🙂

Votes

Translate

Translate
Community Expert ,
Jan 27, 2025 Jan 27, 2025

Copy link to clipboard

Copied

What is the error message? 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 27, 2025 Jan 27, 2025

Copy link to clipboard

Copied

There is no error. And each of the scripts performs if it is alone in the list. somehow some of the scripts seem to stop performance, but they are all just Grep Find/Change. And i try to catch the errors, but they do not appear...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 27, 2025 Jan 27, 2025

Copy link to clipboard

Copied

Then you would've to share your example files. 

 

Do you have diacritics / cyrylic characters - anywhere in the file path?

 

Like the name of the user account in the system?

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 27, 2025 Jan 27, 2025

Copy link to clipboard

Copied

LATEST

Oh I've just got it... It seems the problem must be in the loops where I use the same named variable , and it's JS... Thanks! I've been trying to fix it for 5 days... Like always so obvious solve when you realize it...  
So in some scripts your i in loop becomes bigger than the number of elements in list and it just ends. Be careful with variables namings! 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines