🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #763

Re: it can not search the text with Grep, what's wronge with my code?

#763
From: Peter Kahrel
Date: Mon, 02 Mar 2009 12:37
21 lines
1503 bytes
you say, 

      if (app.changeGrepPreferences.pointSize=app.findGrepPreferences.pointSize)




but for comparison, you need ==, not =. There's also not much point comparing these two if you haven't set them first. And when you set them like that there's no need to compare them, if you follow me.

You need something like this:

var myFoundItem = app.findGrep (); 
   for (var i = 0; i < myFoundItem.length; i++) 
     if (myFoundItem[i].pointSize == 11 && myFoundItem[i].fontStyle == 'Italic') 
         // do something



The way you've coded the last part of the script and that you use 'myFoundItem' rather than 'myFoundItems' suggest that you don't really understand what app.findGrep () does. Before you continue to tinker with existing scripts you should take some time to learn more about JavaScript. It'll save you much time in the end.

Peter
Technical Details
Message-ID: <59b7f00d.10@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newshub.sdsu.edu!webcrossing
References: <59b7f00d.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,72cfdd46072287ca
X-Google-Attributes: gidf939a,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Peter Kahrel" <kahrel@kahrel.plus.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: Re: it can not search the text with Grep,
 what's wronge with my code?
Message-ID: <59b7f00d.10@webcrossing.la2eafNXanI>
Date: Mon, 2 Mar 2009 04:37:37 -0800
References: <59b7f00d.-1@webcrossing.la2eafNXanI>
Lines: 22
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit