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

Javascript error 23 when running find/replace script

Explorer ,
Apr 14, 2024 Apr 14, 2024

Copy link to clipboard

Copied

Hello, 

 

First - I am new to scripting.

 

I have been doing manual find/replaces on some documents I have and thought this should be a slam dunk for the find/replace script in InDesign, but I am getting an error and not sure why.

 

Here is the error:

 

Screenshot 2024-04-14 at 10.04.55.png

 

 

All I have done is add the first four lines to the list of find/changes in the supporting text file (file attached) and added // in front of the existing/default ones so they are ignored.

 

I'll admit the find/replace operations I am using are not very sophisticated,  but they achieve my exact desired ends and save me a ton of time - to be able to run them all in order at the click of a button would be even better.

 

 

Your help is appreciated.

 

Baxter

 

 

 

TOPICS
Scripting

Views

630

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 Expert , Apr 17, 2024 Apr 17, 2024

Every field has to be seperated with a single tab character in two of your records the changeTo is preceded by I suppose double tabs and hence the issue. Fix it and it will work. Check the file which worked for me

https://www.dropbox.com/scl/fi/xjvf5otvz6bevgp9gxxeq/FindChangeList.txt?rlkey=1aq0xzz1bqqy13vrtlsrhx28h&dl=0

-Manan

Votes

Translate

Translate
Community Expert ,
Apr 14, 2024 Apr 14, 2024

Copy link to clipboard

Copied

Change double return to single return
Change returns to XX 

 

I'm not a JS expert but should't comments like the ones above be commented? Right now they appear as part of script code.

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 ,
Apr 14, 2024 Apr 14, 2024

Copy link to clipboard

Copied

the attached file is the .txt support file, not the script itself, and that seems to be the correct formatting looking back over several versions.

What's strange is the script doesn't seem to have changed in years, and the error seems to be in the running of the script. Only thing I see different in the text file is the samples all end the comment with a period, but the new entries do not.

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
Explorer ,
Apr 14, 2024 Apr 14, 2024

Copy link to clipboard

Copied

I have just spent some time with this - stripped the txt file back to bare minimums and started building it one by one.  Oddly enough I got some lines to work by themselves, then later they would fail?  Scripting and programming is well above by head, but this seemed pretty straightforward.

 

As a work-around, I have just created custom find/replace actions, named them, 1, 2, 3, 4, etc and just serially click through them and Change All.  That is much quicker than I was doing, so I'll take a small win for now.

 

I'll have to research this scripting more later.

 

Many thanks for the comments.

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 ,
Apr 15, 2024 Apr 15, 2024

Copy link to clipboard

Copied

@Baxter416 

 

Can you post a file that stopped working after adding new lines?

 

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
Explorer ,
Apr 15, 2024 Apr 15, 2024

Copy link to clipboard

Copied

It's the txt file in the original post. At the bottom.

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 ,
Apr 15, 2024 Apr 15, 2024

Copy link to clipboard

Copied

just out of curiosity, have you tried adding a period to the end of each new line?

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
Explorer ,
Apr 15, 2024 Apr 15, 2024

Copy link to clipboard

Copied

I haven't, but will absolutely give it a try.  Thanks.

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 ,
Apr 17, 2024 Apr 17, 2024

Copy link to clipboard

Copied

Every field has to be seperated with a single tab character in two of your records the changeTo is preceded by I suppose double tabs and hence the issue. Fix it and it will work. Check the file which worked for me

https://www.dropbox.com/scl/fi/xjvf5otvz6bevgp9gxxeq/FindChangeList.txt?rlkey=1aq0xzz1bqqy13vrtlsrhx...

-Manan

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 ,
Apr 17, 2024 Apr 17, 2024

Copy link to clipboard

Copied

Good catch @Manan Joshi.

 

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
Explorer ,
Apr 17, 2024 Apr 17, 2024

Copy link to clipboard

Copied

Briiillliant!   Thank you!   Yes, I see the issue now. I went back and cleaned things up and the script works just fine now!  You have saved me a lot of time, my friend - I learned something today.

 

Cheers

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 ,
Apr 17, 2024 Apr 17, 2024

Copy link to clipboard

Copied

@Baxter416 

 

You should use some Text Editor that let you control TABstops and show them - this is a screenshot from Notepad2:

RobertTkaczyk_0-1713377388032.png

Here they are set to 10 - I had them set to 4 before and missed the doubles.

 

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
Explorer ,
Apr 17, 2024 Apr 17, 2024

Copy link to clipboard

Copied

Excellent - thank you.  I will look into that type of editor. Easy to see the inconsistencies in that type of view.

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 ,
Apr 18, 2024 Apr 18, 2024

Copy link to clipboard

Copied

LATEST

Almost all editors have this option of showing hidden characters. So check if your current editor has it and if yes then switch the option on and you are all set.

-Manan

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