Thread View: adobe.scripting.indesign
8 messages
8 total messages
Started by Sharon_Entona
Sat, 07 Mar 2009 05:42
Need help with Javascript
Author: Sharon_Entona
Date: Sat, 07 Mar 2009 05:42
Date: Sat, 07 Mar 2009 05:42
7 lines
1152 bytes
1152 bytes
Hi all, I'm new to Javascript and need some help setting up a script for Indesign. I have a 100pg document which has about 8 price tickets on each page. On each ticket there is a BIG price and a little price. The dollar signs and cents values are superscripted for the BIG price... however, all instances of anything less than $1.00 is shown as (for example) $0.50. I've managed to get rid of all the "$0." but I need a script that will search for a text box with just two digits in it and then add a superscripted "�" sign after it. So what is shown as 99 will show as 99� Hope this makes sense, appreciate any help!
Re: Need help with Javascript
Author: Peter Kahrel
Date: Sat, 07 Mar 2009 08:49
Date: Sat, 07 Mar 2009 08:49
8 lines
973 bytes
973 bytes
In CS3 and CS4 you don't need a script for this. Using the GREP tab in the Find/Change dialog, do this: Find what: \A(\d\d)\z Change to: $1� \A stands for "beginning of story", \d is "any digit", \z means "end of story", so by searching for \A\d\d\z you're looking for stories that consist of two digits. This would work only if those two-digit text frames are not threaded. Peter
Re: Need help with Javascript
Author: S_E
Date: Sat, 07 Mar 2009 21:13
Date: Sat, 07 Mar 2009 21:13
1 lines
704 bytes
704 bytes
Thanks Peter, but I'm working on CS2
Re: Need help with Javascript
Author: xbytor
Date: Sat, 07 Mar 2009 21:52
Date: Sat, 07 Mar 2009 21:52
8 lines
1046 bytes
1046 bytes
S_E@adobeforums.com wrote: > Thanks Peter, but I'm working on CS2. So i need a script that will find all instances of 10-99 and add a � sign str.replace(/\$0\.(\d\d)/g, "$1�"); In other words, replace the $0.50 with 50� in one pass instead of two. Not sure how this would look in InDesign-grep syntax. The str.replace call uses plain RegExp syntax.
Re: Need help with Javascript
Author: Peter Kahrel
Date: Sun, 08 Mar 2009 10:24
Date: Sun, 08 Mar 2009 10:24
12 lines
929 bytes
929 bytes
In CS2 it's a little more complicated. As X said, you can replace $0.50 to 50� in one pass:
myStories = app.activeDocument.stories.everyItem().getElements();
for (i = 0; i < myStories.length; i++)
if (myStories[i].contents.length == 5)
myStories[i].contents = myStories[i].contents.replace (/\$0\.(\d\d)/, "$1�")
Peter
Re: Need help with Javascript
Author: S_E
Date: Mon, 09 Mar 2009 07:24
Date: Mon, 09 Mar 2009 07:24
1 lines
592 bytes
592 bytes
Thank you guys, it worked!
Re: Need help with Javascript
Author: S_E
Date: Mon, 09 Mar 2009 22:47
Date: Mon, 09 Mar 2009 22:47
1 lines
671 bytes
671 bytes
Woops, it doesn't seem to work if there's an anchored object in the text box! Can I get some help please?
Re: Need help with Javascript
Author: Peter Kahrel
Date: Tue, 10 Mar 2009 09:37
Date: Tue, 10 Mar 2009 09:37
10 lines
971 bytes
971 bytes
it doesn't seem to work if there's an anchored object in the text box!
We could have told you that:) If each and every $0.nn price is to be changed to nn�, irrespective of whatever else is in your text frames, then you can get around it easily. If not, it gets a bit tougher.
Peter
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads