Skip to main content
Lendroid-ZfUiZ6
Participant
May 5, 2009
Answered

[JS, CS3] Please help--need to search text & then insert at find

  • May 5, 2009
  • 1 reply
  • 825 views

Hi all,

I have a nifty script that I use to make stacked fractions by inserting an inline textframe.  It has a dialog which allows you to enter the numerator and denominator.

Now I would like to modify this script to automatically search for fractions within text (for example, 5/16) and replace that fraction with my inserted textframe.

The problem is I cannot figure out how to search for the word containing the slash character and then get the insertion point so I can add my textframe as an inline.  Once I find the word with the slash (the fraction), I think I can split the contents of the fraction at the slash to get the numerator & denominator.  Just cannot pop that textframe in there at that point and replace the word.

Have I made this clear enough for anyone who might be able to help?

Regards,

Len Swierski

This topic has been closed for replies.
Correct answer Dave_Saunders

Hi Len,

You just sent me on a trip down memory lane. I wrote about this very issue very soon after CS hit the street with JavaScript for the first time. On this page:

http://www.pdsassoc.com/index.php?Nav=javassub&Ban=SettingFractions&Info=jstutorials/SettingFractions/index.html

you'll find what I think is a relevant discussion. I required the user to select a slash but that's where you'll be after your script has found a slash. Hope this helps. I was perhaps a tad pedantic on that page but it was all very new at the time.

Dave

1 reply

Dave_SaundersCorrect answer
Inspiring
May 5, 2009

Hi Len,

You just sent me on a trip down memory lane. I wrote about this very issue very soon after CS hit the street with JavaScript for the first time. On this page:

http://www.pdsassoc.com/index.php?Nav=javassub&Ban=SettingFractions&Info=jstutorials/SettingFractions/index.html

you'll find what I think is a relevant discussion. I required the user to select a slash but that's where you'll be after your script has found a slash. Hope this helps. I was perhaps a tad pedantic on that page but it was all very new at the time.

Dave

Lendroid-ZfUiZ6
Participant
May 5, 2009

Thanks Dave!

This will get me where I need to be.

Regards,

Len Swierski

Kasyan Servetsky
Legend
May 6, 2009

If you ubdate to CS4, you can do it without script by creating a GREP style and setting its To Text parameter to \d+/\d+

Kasyan