Skip to main content
Andreas Jansson
Inspiring
May 13, 2009
Question

JS: finding replacing special characters ID desktop / ID Server

  • May 13, 2009
  • 1 reply
  • 3115 views

Hi,

Is there a differnce in the find / replace routines between desktop and server version of InDesign? I know it should work the same way as in the interface, and it does work when running on the desktop version.

I'm trying to replace a character sequence (a previously "encoded" indent to here) with the real "indent to here" special character.

This works in desktop as well as server versions:

    app.findTextPreferences.findWhat = "roof-i";
    app.changeTextPreferences.changeTo = "roof-a";
    app.changeText();

(replacing the word "roof-i" with the word "roof-a")

But this does not work, nothing happens in the Server version:

    app.findTextPreferences.findWhat = "roof-i";
    app.changeTextPreferences.changeTo = "^i";
    app.changeText();

However, on my client tests with the script, the word roof-i becomes the real indent to here special character, just as when writing ^i in the find/change dialogue.

Is there something special to regard when replacing special characters on the server version. I've also tried using the grep version, changeTo set to ~i instead, but with the same results (nothing happens on the server).

Best regards,

Andreas Jansson

This topic has been closed for replies.

1 reply

May 13, 2009

Hi Andreas,

Nothing should happen in either case--you need to address the document, story, or text you want to perform the find/change operation on. This line:

app.changeText();

...should be something like:

app.documents.item(0).changeText();

I do see the special character in the list of special characters for InDesign Server (SpecialCharacters.indentHereTab), so it should work.

Thanks,

Ole

Adobe Expert
May 14, 2009

Ole,

>Nothing should happen in either case--you need to address the document, story, or text you want to perform the find/change operation on

app.changeText() and app.changeGrep() target all open documents: they are the equivalent of picking "All documents" in the Find/Change dialog.

Peter

Jongware
Brainiac
May 14, 2009

My problem is that the ^i does not result in the indent to here, on the server version.

(I do have a story object to send to my replace function, but for simplicity I used the app.change... call while testing - it made no difference to use the story object, still no replace on the InDesign server version.)

I thought about using the special character like this: app.changeTextPreferences.changeTo = SpecialCharacters.indentHereTab;

...But I read in another thread that you should use the same characters as in the user interface in InDesign (in this case ^i or ~i for grep), and that should be the way as I see it. Using SpecialCharacters.indentHereTab results in error

" Invalid value for set property 'changeTo'. Expected String or NothingEnum enumerator, but received 1397319796. "

Andreas


Perhaps there is a problem with special character escaping. Try with double or triple '^' (in regular text find) or '~' (in GREP find). Or insert them as hex characters: <005E> and <007E>.