Copy link to clipboard
Copied
Hello! I have simple code, that executes some scripts for Indesign, which work when i run them manually from app Script pannel. But somehow they work for scripts character styles and do not work when i call scripts with changeGrep(). What could be the problem? Or may be there is a better way to do this? Can you recommend something for
(I removed path for privacy, but it seems to be ok, because some of the scripts definitely execute)
Hi @Viktoriia_ It seems surprising that findGrep is the issue here. These are the tests I would suggest:
1. Check that the path(s) are working okay, eg.
if (!File(myPath).exists)
alert('Script not found at "' + myPath + '".');
2. Open one of the failing scripts (a findGrep one?) and simplify it to the point where it either (a) now works—in which case the last thing you removed is probably causing the issue, or (b) is as simple as it can be—in which case we know that that last simple thin
...Copy link to clipboard
Copied
Have you seen FindChangeByList script included with InDesign?
Do you have any "diacritics" in your path to the Scripts pallet?
Copy link to clipboard
Copied
And are you on a Mac or a PC?
If Mac - maybe POSIX path problem is invloved?
https://helpx.adobe.com/indesign/kb/user-dictionaries-missing-hfs-path-dropped.html
Copy link to clipboard
Copied
Hi @Viktoriia_ It seems surprising that findGrep is the issue here. These are the tests I would suggest:
1. Check that the path(s) are working okay, eg.
if (!File(myPath).exists)
alert('Script not found at "' + myPath + '".');
2. Open one of the failing scripts (a findGrep one?) and simplify it to the point where it either (a) now works—in which case the last thing you removed is probably causing the issue, or (b) is as simple as it can be—in which case we know that that last simple thing is causing the issue. (If you can make a simple script, pared down to the bare bones that still shows the issue, but it still isn't clear what's going on, please post that script here.)
Another thought is that some scripts perform operations such as $.fileName which will possibly return a different path depending on whether the script is run via a "script runner" or via the scripts panel or straight from an IDE, which can cause errors.
- Mark
Copy link to clipboard
Copied
I wonder how and why but it starts to work when i add these two lines, even though there is no alert, so all pathes are correct. But there are still some cases of scripts that do not run, I'll try to figure it out by myself.
Thank you very much!
Copy link to clipboard
Copied
Hi Mark!
I'm still working with this script, and I suppose it does not work because of Kyrylics, typographer quotes,
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi @Viktoriia_ sorry for late reply. Text encoding can be tricky. You have already saved the scripts as UTF-8 with BOM which is good. Another thing you can add to the script runner—and maybe each individual script?—is the following line, near the start of the script (before the evals):
$.appEncoding = 'UTF-8';
This sets ExtendScript's own encoding rule, so it might help.
- Mark
Copy link to clipboard
Copied
Copy link to clipboard
Copied
@Robert at ID-Tasker I think appEncoding comes into play when doScript takes a File as parameter. Also evalFile. It doesn't seem to be a factor when just running a script "directly".