6 Replies Latest reply on Sep 17, 2015 2:22 AM by hamdifem

    operation between pages

    hamdifem Level 1

      between certain pages

      I wrote the code to count objects

      Where can I make mistakes

       

      var myDoc = app.activeDocument;  
      var myLayerObj = app.activeDocument.layers.item("Katman 1").allPageItems;
      var myArray = new Array();
      var offset = Number(myDoc.pages[0].name);
      var w = new Window("dialog", "COUNTFRAME");
      w.orientation = "row";
      w.add("statictext", [0, 0, 45, 25], "Pagess");
      var startP = w.add("edittext", [0, 0, 45, 20], offset);
      startP.active = true;
      var finalyP = w.add("edittext", [0, 0, 45, 20], (offset + myDoc.pages.length - 1).toString());
      var okButton = w.add("button", undefined, "OK", {name: "ok"});
      var cancelButton = w.add("button", undefined, "Cancel", {name: "cancel"});
      if (w.show () == 1){
      var firstP = Number(startP.text) - offset;
      var endP = Number(finalyP.text) - offset;
      for(var j = firstP ; j <= endP ; ++j) {
      for (t = 0; t<myDoc.pages[j].myLayerObj.length; ++t){ // ???
      var myObj = myLayerObj[t];
      if(myObj instanceof TextFrame &&  myObj.appliedObjectStyle.name == "tmc"){
      myArray.push(myObj);
      }
      }
      }
      alert(myArray.length);
      }