3 Replies Latest reply on May 18, 2012 2:19 AM by Iain Robinson

    [JS][CS5.5] Syntax query

    Iain Robinson

      Hi all

       

      After another long gap I'm coming back to scripting again and I've probably forgotten most of what I learned here before. I'm trying to capture the contents of the first paragraph (which identifies what sort of article it is) so I can then analyse it and do different things depending on what it finds. I think I can do the analysis (famous last words!) but I'm stuck at the first hurdle.

       

      If I use a para style to identify the first para (which obviously means I'd have to ask the client to style it) it works okay;

       

      var myDoc = app.activeDocument;

      //Find the first para in the story (which contains the article type)

      app.findGrepPreferences.appliedParagraphStyle = "Identifier";

      firstPara = myDoc.findGrep();

      articleType = firstPara[0].contents;

      alert(articleType);

       

      But if I try to identify the first para using GREP (using app.findGrepPreferences.findWhat  = "\A^.+$";), which would be better as the para wouldn' thave to be styled, I get an "undefined is not an object error". Running a manual GREP search in ID with \A^.+$ finds the first para so it must be the syntax is wrong in my code.

       

      Can anyone point out where I am going wrong please?

       

      thanks,

      Iain