Skip to main content
Participant
June 10, 2010
Question

Select text with character style applied.

  • June 10, 2010
  • 1 reply
  • 526 views

Hello everybody...

I need some help with this problem.

I've got a text spotted here and there with Jewish words. As you certainly know, it could happen that you need to "flip" Jewish words (as arabic ones and so on...) because the correct writing sense is from right to left.

The usual script used is ReverseText, but you need to select each Word and then run the script.

Instead, I'd like to select every instance of the Character Style JEWISHWORD I assigned...

What I'd have to put before the reverse command?
JEWISHREVERSE = app.selection[0].contents;

JEWISHREVERSE = JEWISHREVERSE.split("").reverse().join("");

app.selection[0].contents = JEWISHREVERSE;

Thank you so much.
Val.

This topic has been closed for replies.

1 reply

Jongware
Community Expert
Community Expert
June 11, 2010

A search, perhaps.

app.findTextPreferences = null;

app.findTextPreferences.appliedCharacterStyle = "JEWISHWORD";

result = app.activeDocument.findText();

while (result.length)

{

   str=result.pop();

  JEWISHREVERSE = str.contents;

  JEWISHREVERSE = JEWISHREVERSE.split("").reverse().join("");

  str.contents = JEWISHREVERSE;

}

Off the top of my head & untested, so it might not work right away.

(OT: "Jewish" is a faith. You are referring here to the script, which is named the same as the only language I know that uses it: "Hebrew" (as in "The Hebrew language is usually written in the Hebrew script").)

Harbs.
Legend
June 11, 2010

You can shorten that a bit:

str=result.pop();

str.contents = str.contents.split("").reverse().join("");

Harbs

valaeriaAuthor
Participant
June 11, 2010

Really more professional...

thanks a lot!

My version was for dummies... (I need to call everything with its own name... and in general I hope that this could help in giving me a correct answer!)