6 Replies Latest reply on Jan 18, 2015 10:30 PM by Teetan VK

    Change script function

    Teetan VK Level 1

      Hi everyone

       

      I use this script:

       

      app.selection[0].contents=”[undefine]”;

      app.selection[0].underline=true;

       

      to change whatever I selected

      01.png

      change to [undefine], then make it underline.

       

      02.png

       

      but:

       

      if I add the
      [undefine] into inserpoint,

       

      3.jpg

      the comeout will not underline.

       

      4.jpg

       

       

       

      Can someone help me to change the functions:

       

      not matter the
      selection or inserpoint I want to get the [undefine] with underline.

       

      thanks

      Regard

       

      Teetan

        • 1. Re: Change script function
          Sajeev Sridharan Level 4

          Try this,

           

          if(app.selection[0].constructor.name == "InsertionPoint")
          {app.selection[0].insertionPoints[0].underline=true; app.selection[0].contents="[undefine]";}
          else{app.selection[0].underline=true;app.selection[0].contents="[undefine]";}
          

           

           

          Vandy

          • 2. Re: Change script function
            Teetan VK Level 1

            Hi

            thanks everyone

             

            but

            is that possibly to change it aim to work in cells

             

            for instance:

             

            if I selected a lot of cells with text

            that script can change it the contents to [undefine] and make it underline

            or

            if I selected a lot of empty cells

            the script can add [undefine] into cells with underline

             

            thanks

             

            Teetan


            • 3. Re: Re: Change script function
              Sajeev Sridharan Level 4

              Try this,

               

              if(app.selection[0] instanceof InsertionPoint)
              {app.selection[0].insertionPoints[0].underline=true; app.selection[0].contents="[undefine]";}
              else if(app.selection[0] instanceof Cell)
              {app.selection[0].texts[0].select();app.selection[0].underline=true;app.selection[0].contents="[undefine]";}
              else{app.selection[0].underline=true;app.selection[0].contents="[undefine]";}
              

               

               

              Vandy

              • 4. Re: Change script function
                Teetan VK Level 1

                Sorry Vandy

                 

                I mean each cell inserted an "[undefine]"

                not just one cell

                 

                Teetan

                • 5. Re: Re: Change script function
                  Sajeev Sridharan Level 4

                  Try this,

                   

                  var mySelection = app.selection[0];
                  if(mySelection instanceof InsertionPoint)
                  {mySelection.insertionPoints[0].underline=true; mySelection.contents="[undefine]";}
                  else if(mySelection instanceof Cell)
                  {for(i=0; i<mySelection.cells.length; i++){mySelection.cells[i].texts[0].select();app.selection[0].underline=true;app.selection[0].contents="[undefine]";}}
                  else if(mySelection instanceof Table)
                  {for(i=0; i<mySelection.cells.length; i++){mySelection.cells[i].texts[0].select();app.selection[0].underline=true;app.selection[0].contents="[undefine]";}}
                  else{mySelection.underline=true;mySelection.contents="[undefine]";}
                  

                   

                   

                  Vandy

                  • 6. Re: Change script function
                    Teetan VK Level 1

                    Thank you Vandy

                     

                    thank you very much, appreciate

                     

                    Teetan