0 Replies Latest reply on Jun 3, 2013 7:04 AM by paolbot

    New document dimension: options

    paolbot

      I found this script to create a new document from a radiobutton choice of dimension; it works very fine, but I need to have the possibility to add a window to enter a personal width if I need to create a new document with no standard dimension.

      Can someone help me?

       

      Thnx, Paolo

       

       

      var UIresult = myDisplayDialog();

      if (UIresult.rb[0]){createDocument("41.3", UIresult.docHeight);}

      if (UIresult.rb[1]){createDocument("86.1", UIresult.docHeight);}

      if (UIresult.rb[2]){createDocument("130.9", UIresult.docHeight);}

      if (UIresult.rb[3]){createDocument("175.7", UIresult.docHeight);}

      if (UIresult.rb[4]){createDocument("220.5", UIresult.docHeight);}

      if (UIresult.rb[5]){createDocument("265.3", UIresult.docHeight);}

      if (UIresult.rb[6]){createDocument("310.1", UIresult.docHeight);}

      function createDocument(docHeight, docWidth)

      {

      var myDocument = app.documents.add();

      with(myDocument.documentPreferences){

      pageHeight = docHeight + "mm";

      pageWidth = docWidth + "mm";

      pagesPerDocument = 1;}

      }

      function myDisplayDialog()

         {

              var myDialog = new Window ('dialog', 'New document');

              myDialog.alignChildren = "left";

              var rg0 = myDialog.add ('group');

              rg0.add('statictext',undefined, 'number of column:');

                var rb1 = rg0.add('radiobutton',undefined, '1');

                var rb2 = rg0.add('radiobutton',undefined, '2');

                var rb3 = rg0.add('radiobutton',undefined, '3');

                var rb4 = rg0.add('radiobutton',undefined, '4');

                var rb5 = rg0.add('radiobutton',undefined, '5');

                var rb6 = rg0.add('radiobutton',undefined, '6');

                var rb7 = rg0.add('radiobutton',undefined, '7');

                rg0.add('statictext',undefined, 'column');

                rb1.value = true;

                var rg1 = myDialog.add ('group');

              rg1.add('statictext',undefined, 'Height:');

              var docuHeight = rg1.add('edittext',undefined, '100');

              rg1.add('statictext',undefined, 'mm');

              var rg2 = myDialog.add ('group');

              rg2.alignment = "right";

              rg2.add('button', undefined, 'Cancel ', {name: 'cancel'});

              rg2.add('button', undefined, 'OK', {name: 'ok'});

      var myResult = myDialog.show();

      if (myResult == 1)

      {

           return {rb : [rb1.value, rb2.value, rb3.value, rb4.value, rb5.value, rb6.value, rb7.value], docHeight : docuHeight.text};

      }

      if (myResult == 2)

      {

           exit();

      }

      }