JavaScript Error when running FindChangeByList script in CS4
Hello there. InDesign CS4 user here running 10.4.11 on a PowerPC G5.
I recently learned GREP and thought of some very useful find/changes that meet our company's needs before laying out text. All of these find/changes work as desired when run using the find/change dialog box. However, when I tried to replace the existing items in the findchangelist.txt file, I'm getting the following Javascript error:
JavaScript Error!
Error Number: 25
Error String: Expected: :
File: /Applications/Adobe InDesign CS4/Scripts/Scripts Panel/Samples/JavaScript/FindChangeByList.jsx
Line: 172
Source: app.doScript(myString, ScriptLanguage.javascript);
I saw at least one other person has had this problem, but there was no reply posted. I also found similar complaints about the script that comes with InDesign CS4 being "broken," but don't know JavaScript well enough to fix the error. Can anyone help? It would be greatly appreciated.
Matthew
P.S. - In case it's helpful, I'll include the script from the text file below. The only instances where I'm applying formatting to text (instead of replacing text) are the 3rd and 10th lines. This is my first experience with scripting, so go easy on me. ![]()
//Pre-layout.txt
//A support file for the InDesign CS4 JavaScript FindChangeByList.jsx
//
//This data file is tab-delimited, with carriage returns separating records.
//
//The format of each record in the file is:
//findType<tab>findProperties<tab>changeProperties<tab>findChangeOptions<tab>description
//
//Where:
//<tab> is a tab character
//findType is "text", "grep", or "glyph" (this sets the type of find/change operation to use).
//findProperties is a properties record (as text) of the find preferences.
//changeProperties is a properties record (as text) of the change preferences.
//findChangeOptions is a properties record (as text) of the find/change options.
//description is a description of the find/change operation
//
//Very simple example:
//text {findWhat:"--"} {changeTo:"^_"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Find all double dashes and replace with an em dash.
//
//More complex example:
//text {findWhat:"^9^9.^9^9"} {appliedCharacterStyle:"price"} {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false} Find $10.00 to $99.99 and apply the character style "price".
//
//All InDesign search metacharacters are allowed in the "findWhat" and "changeTo" properties for findTextPreferences and changeTextPreferences.
//
//If you enter backslashes in the findWhat property of the findGrepPreferences object, they must be "escaped"
//as shown in the example below:
//
//{findWhat:"\\s+"}
//
text {findWhat:"--"} {changeTo:"^_"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Find all dash-dash and replace with an em dash.
grep {findWhat:"⁄"} {changeTo:"/"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Find all funky slashes and replace with regular slashes.
grep {findWhat:"\d\/\d"} {myText.otfFraction = true} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Format opentype fractions.
grep {findWhat:"(?<=\d) (?=\d\/\d)"} {changeTo:""} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Remove all spaces from mixed fractions.
grep {findWhat:"\x{20}\x{20}+"} {changeTo:"\x{20}"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Find multiple spaces and replace with single space.
grep {findWhat:" +$"} {changeTo:""} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Find trailing spaces and delete.
grep {findWhat:"([\d\/]+)-([\d\/]+)"} {changeTo:"$1–$2"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Find hyphens in number ranges and replace with en-dashes.
grep {findWhat:"(?<=\d) (?=seconds?|minutes?|hours?|days?|weeks?|months?|teaspoons?|tablespoons?|cups?|pounds?|ounces?|degrees?|inch|inches|\bto\b|\bby\b)"} {changeTo:"~S"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Replace spaces after some numbers with non-breaking spaces.
grep {findWhat:"(\d+)-([\u\l]+)"} {changeTo:"$1‑$2"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Replace hyphens after numbers with non-breaking hyphens.
grep {findWhat:"([\u\l]+(?=[-‑–]))|((?<=[-‑–])[\u\l]+)"} {myText.noBreak = true} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Find all hyphenated words and set to no-break.
