5 Replies Latest reply on Nov 7, 2012 2:19 AM by Jump_Over

    how to set if, else???


      for example:

      if i want to text convert to table.


      If have ";" x 4




      (script 1)

      Header 1Header 2Header 3Header 4




      if have ";" x5

      (script 2)

      var myTable = app.selection[0].convertToTable(";","\r");




      Header 1Header 2Header 3Header 4Header 5


      and if have ";"x6 =(script 3), ";" x 7 = (script 4), ";" x8  (scr.......



      i want only use a script to do, how can i do that??


      thankyou>< love your

        • 1. Re: how to set if, else???
          [Jongware] Most Valuable Participant

          You don't have to count the number of ;'s. The function convertToTable will never create more columns than needed.

          • 2. Re: how to set if, else???
            AlienLai Level 1

            thankyou your help.

            but i want to set colnum wifth.


            different colnum number different width...


            example: if ";" x3


            col1 width = "90 mm" col2 = "30mm" col3 = "30mm"


            of ";" x 4


            col1 width = "75mm" cold 2 width = "25mm" col 3 width = "25mm" col 4 width = "25mm"


            because i have many script 1 for 3 column, script 2 for 4 column.

            how can i integrate to one script.

            • 3. Re: how to set if, else???
              Jump_Over Level 5



              Could you find a rule when calculating columns width?

              Could it be: 1st column is 3 times wider then the rest?

              If your table width is a textFrame width - all the rest is mathematics

              and can be done in one loop.

              • 4. Re: how to set if, else???
                AlienLai Level 1

                i see, but i'm asking wrong my english to bad....


                actually i'm not want to set colnum width.....


                i need count the character ";".....sorry...


                if         1;2;3;4       <----have three ";"


                run script 1


                if 1;2;3;4;5             <------have four ";"


                run script 2


                if       1;2;3;4;5;6   <--------have five ";"


                run script 3

                • 5. Re: how to set if, else???
                  Jump_Over Level 5



                  So you could use a switch:


                  var whichScript = myTable.columns.length;


                  var whichScript = app.selection[0].texts[0].contents.split(";").length;


                  and after this:




                  case 1: {do something1; break;}

                  case 2: {do something2; break;}


                  case 3: {do something3; break;}