1 Reply Latest reply on Nov 18, 2010 8:06 AM by AdobeScripts

    Am i coding this right?

    ian_gozer

      This could potentially be the start of quite a big project so im wanting to be sure im starting out on the right foot.

       

      I understand that there are a few different coding styles that work and they seem to be fairly subjective as to which is best.

       

      Im just looking for advice as to if the code i have looks like its heading in the right direction?

       

      If anyone has any advice on the comments ive added too would be good!

       

      var ImposeDialog = new Window ("dialog", "Impose");
      
      var FileNameGroup = ImposeDialog.add ("group");
      FileNameGroup.add ("statictext", undefined, "Name:");
      var FileNameField = FileNameGroup.add ("edittext", undefined, "PlaceFile");  // Need to show end of path not start OR crop to ..../ +filename but would then need filename var and filelocation var
      FileNameField.preferredSize = [150,20];
      FileNameField.active = true;
      var BrowseButton = FileNameGroup.add ("button", undefined, "Browse");
          BrowseButton.onClick = function () {var BrowseFilePath = File.openDialog("Choose a file","PDF Files:*.pdf");
              if(BrowseFilePath != null)FileNameField.text = BrowseFilePath.fsName;
      }
      
      var container = ImposeDialog.add("panel");
      
      var RowColumnGroup = container.add ("group");
      RowColumnGroup.add ("statictext", undefined, "Rows:");
      var RowsField = RowColumnGroup.add("edittext", undefined, "1");  // Need to make integer only
      
      RowsField.characters = 2;
      RowColumnGroup.add ("statictext", undefined, "Columns:");
      var ColumnsField = RowColumnGroup.add("textEditboxes", undefined, "1");  // Need to make integer only
      ColumnsField.characters = 2;
      
      container.add ("panel", [0,0,200,3]);
      
      var BleedGroup = container.add ("group");
      var TittleBleedGroup = BleedGroup.add ("group");
      TittleBleedGroup.orientation = "column";
      TittleBleedGroup.add ("statictext", undefined, "Bleed:");
      var BleedCheck = TittleBleedGroup.add ("checkbox", undefined, "Equal");
      BleedCheck.value = true;
      // if (BleedCheck.value = true) dissable bottom left and right
      //BleedCheck.value onChange listener enable/disable
      
      var TopBleedGroup = BleedGroup.add ("group");
      TopBleedGroup.orientation = "column";
      TopBleedGroup.add ("statictext", undefined, "Top");
      var TopBleedField = TopBleedGroup.add("edittext", undefined, "2");  // Need to make measurement only
      
      var BottomBleedGroup = BleedGroup.add ("group");
      BottomBleedGroup.orientation = "column";
      BottomBleedGroup.add ("statictext", undefined, "Bottom");
      var BottomBleedField = BottomBleedGroup.add("edittext", undefined, "2");  // Need to make measurement only
      BottomBleedField.enabled = false;
      
      var LeftBleedGroup = BleedGroup.add ("group");
      LeftBleedGroup.orientation = "column";
      LeftBleedGroup.add ("statictext", undefined, "Left");
      var LeftBleedField = LeftBleedGroup.add("edittext", undefined, "2");  // Need to make measurement only
      LeftBleedField.enabled = false;
      
      var RightBleedGroup = BleedGroup.add ("group");
      RightBleedGroup.orientation = "column";
      RightBleedGroup.add ("statictext", undefined, "Right");
      var RightBleedField = RightBleedGroup.add("edittext", undefined, "2");  // Need to make measurement only
      RightBleedField.enabled = false;
      
      container.add ("panel", [0,0,200,3]);
      
      var MarksGroup = container.add ("group");
      var TittleMarksGroup = MarksGroup.add ("group");
      TittleMarksGroup.orientation = "column";
      TittleMarksGroup.add ("statictext", undefined, "Marks:");
      var CropsCheck = TittleMarksGroup.add ("checkbox", undefined, "Crops");
      CropsCheck.value = true;
      var RegCheck = TittleMarksGroup.add ("checkbox", undefined, "Registration");
      RegCheck.value = true;
      var ColourbarCheck = TittleMarksGroup.add ("checkbox", undefined, "Colourbars");
      ColourbarCheck.value = true;
      
      var XCropsGroup = MarksGroup.add ("group");
      XCropsGroup.orientation = "column";
      XCropsGroup.add ("statictext", undefined, "X-offset");
      var XCropsField = XCropsGroup.add("edittext", undefined, "2");  // Need to make measurement only
      
      var YCropsGroup = MarksGroup.add ("group");
      YCropsGroup.orientation = "column";
      YCropsGroup.add ("statictext", undefined, "Y-offset");
      var YCropsField = YCropsGroup.add("edittext", undefined, "2");  // Need to make measurement only
      
      
      
      
      var ButtonGroup = ImposeDialog.add ("group");
      ButtonGroup.alignment = "right";
      ButtonGroup.add ("button", undefined, "OK");
      ButtonGroup.add ("button", undefined, "Cancel");
      
      var dialogResult = ImposeDialog.show()
      
      if (dialogResult == true){
           if(FileNameField.text != "PlaceFile"){ // validate file as workable pdf etc etc
               var PlaceFilePath = FileNameField.text;
               var TotalPlacements = ColumnsField.text * RowsField.text;
               var PlacementsX = RowsField.text;
               var PlacementsY = ColumnsField.text;
               
               
               
               
               Place();
               }
           else{
                            alert("error");
      
          // remove script from memory?
      
               }
      }
       
      else { 
          // remove script from memory?
      }
      
      function Place(){
          alert("place file " + PlaceFilePath + TotalPlacements +"times");
      }
          // remove script from memory?
      
      
      

       

      PS If anyone knows of a script that already does this ( i looked for a couple of days) then a heads up would be great!

       

      Thanks in advance

        • 1. Re: Am i coding this right?
          AdobeScripts Level 3

          ian_gozer wrote:

           

          This could potentially be the start of quite a big project so im wanting to be sure im starting out on the right foot.

          ...

          PS If anyone knows of a script that already does this ( i looked for a couple of days) then a heads up would be great!

          Are you working on Imposition script ?

           

          I have one - but only for Windows platform ...

           

          robin

          www.adobescripts.com