Skip navigation
Matthew.Fry
Currently Being Moderated

RE: FindChangesByList questions

Apr 6, 2012 12:48 PM

I work for a daily newspaper and I am fairly new to the world of InDesign javascripting. I have been making the most of modifying FindChangesByList.jsx and the support file FindChangeList.txt to format articles and sports agate. I am using InDesign CS5.

 

I have a couple of questions and would appreciate any assistance:

 

1. AppliedParagraphStyle question

     How do you refer to a paragraph style when it is in a Style Group folder?

 

2. Grep question

     A. I am trying to get FindChangeList to look for a reporter's name, which is at the beginning of the article and is two upper case words followed by a comma.

          I've tried the following - grep     {findWhat:"\u+ \u+[,]"} - but it doesn't seem to work.

 

     B. Once I find the reporter's name, I would like to add the word "By" in front of the name and remove the comma. I am at a lose how to do this.

 

3. I am also looking for a way to find a reporter's name (which is at the beginning of the article) and then add that reporter's contact information at the end of the article. I am not sure this can be done with FindChangeByList.

 

4. Last question: What book or guide would you commend for someone just learning javascripting in InDesign?

 

Thanks in advance.

 
Replies
  • Currently Being Moderated
    Apr 6, 2012 3:42 PM   in reply to Matthew.Fry

    I'm not a javascripter, but I can answer most of your questions....

     

    1. There isn't an example in the sample text file, but someone posted the answer in a thread that came up as related to this one. This is how you'd do it for a para style called "Blue" in a style group called "Colors":

     

    appliedParagraphStyle:app.activeDocument.paragraphStyleGroups.item("Co lors").paragraphStyles.item("Blue")

     

    2A/B. You're close, but whenever you have something in GREP that starts with a backslash that's running through javascript, you have to escape it by adding another backslash. Also, because of what you want to do in 2B, you'll want to write your search expression with subexpressions so you can delete the comma:

     

    {findWhat:"(\\u+ \\u+)(,)"}

    {changeTo:"By $1"}

     

    To explain what's going on here in the changeTo, you're inserting "By" and a space, followed by the contents of the first set of parentheses ($1 = your reporters' names), and by omitting $2 (the contents of the second set of parens), you'll delete the comma.

     

    Offhand I can't think how you'd do #3 using FindChangeList. It could undoubtedly by done via scripting, provided the story is all in one text flow.

     

    I'll leave it to the folks who do know javascript to recommend a book!

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 6, 2012 4:24 PM   in reply to Mary Posner

    Mary Posner wrote:

     

    I'll leave it to the folks who do know javascript to recommend a book!

     

    4. Peter Kahrel's "Scripting InDesign with Javascript" specifically targets the ID + JS combination: http://shop.oreilly.com/product/9780596802530.do

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 7, 2012 10:48 PM   in reply to Matthew.Fry

    Question 4

    Check out also Automating Adobe InDesign CS4 with ExtendScript by Shirley W. Hopkins

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 9, 2012 3:18 AM   in reply to Matthew.Fry

    {findWhat:"(\\u+( \\u+)+),"}

    {changeTo:"By $1"}

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 9, 2012 9:11 AM   in reply to Matthew.Fry

    3. I am also looking for a way to find a reporter's name (which is at the beginning of the article) and then add that reporter's contact information at the end of the article

    I wrote a somewhat similar script which you can use as a starting point.

     
    |
    Mark as:
  • Currently Being Moderated
    May 11, 2012 10:44 AM   in reply to Matthew.Fry

    You can put something at the end of a story with something like this:

     

    grep{findWhat:"^((.+\\r)+)"}{changeTo:"$1\\rthis is at the end\\r"}{}

     

    So you should be able to have a series of searches for the various writers:

    grep{findWhat:"(By Peter Parker\\r)((.+\\r)+)"}{changeTo:"$1$2Peter Parker is a reporter blah blah\\r"}{}

     

    And then style it with

     

    grep{findWhat:"(is a reporter blah blah)"}{appliedParagraphStyle:"shirttail",changeTo:"$1"}{}
     
    |
    Mark as:
  • Currently Being Moderated
    May 23, 2012 10:47 AM   in reply to Matthew.Fry
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points