4 Replies Latest reply on Jun 11, 2010 1:00 AM by valaeria

    Select text with character style applied.

    valaeria

      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.

        • 1. Re: Select text with character style applied.
          [Jongware] Most Valuable Participant

          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").)

          1 person found this helpful
          • 2. Re: Select text with character style applied.
            Harbs. Level 6

            You can shorten that a bit:

             

            str=result.pop();

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

             

            Harbs

            1 person found this helpful
            • 3. Re: Select text with character style applied.
              valaeria Level 1

              THANK YOU SO MUCH!!!!

               

              I know you are thinking that maybe I'm a neophyte in scripting if I'm non able to think a correct search with an attribute... and it is exactly that... This is my second time with scripting, because until now I always solved all my text problems with GREP.

              (and the first time was adapting the FindChangeSupport txt... non really so difficult, even for me )

               

              I debugged (no errors) and tested in the text (and it works perfectly).

               

              Now I learned that at a beginning of a search I had to put

               

              app.findTextPreferences = null;

               

              even if I don't undestand why I have "to clean" the search if it is on the top of my script...

               

               

               

              Thanks again, even for the JEWISH/HEBREW... As you see (and I'm so certain that it sees a lot), I'm not English mother tongue and I'm a bit lacking with lexicon. (and with some constructions too!)

               

              Have a nice weekend!

              • 4. Re: Select text with character style applied.
                valaeria Level 1

                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!)