3 Replies Latest reply on Jun 24, 2008 6:29 AM by [Jongware]

    JS - surrounding selected text with double quotes

      I have a working script which places brackets around selected text in the main body of my document (not in a table), but when I changed the script to insert double curly quotes, the script wont work.

      Why wont this JS work (script stalls on the var line):

      var myObject = (app.selection[0].parent.constructor.name == "Cell") ? app.selection[0].parent.texts[0] : app.selection[0];

      with (myObject)
      {
      insertionPoints[-1].contents = "";
      insertionPoints[0].contents = "";
      }

      while this one does work:

      var myObject = (app.selection[0].parent.constructor.name == "Cell") ? app.selection[0].parent.texts[0] : app.selection[0];

      with (myObject)
      {
      insertionPoints[-1].contents = ")";
      insertionPoints[0].contents = "(";
      }

      Thx Oz

      PS The quotes are showing as three straight quotes above, but in my script they are two straight double quotes surrounding either a right or a left curly double quote.