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

Javascript error 23 when running find/replace script

Explorer ,
Apr 14, 2024 Apr 14, 2024

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
1.1K
Translate
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

Translate
Community Expert ,
Apr 14, 2024 Apr 14, 2024
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.

Translate
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

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.

Translate
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

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.

Translate
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

@Baxter416 

 

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

 

Translate
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

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

Translate
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

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

Translate
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

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

Translate
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

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

Translate
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

Good catch @Manan Joshi.

 

Translate
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

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

Translate
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

@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.

 

Translate
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

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

Translate
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
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

Translate
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