5 Replies Latest reply on Dec 18, 2016 4:59 AM by Wosven

    Why does the page number change

    hamdifem Level 1

      Hello

      I need to change section marker manually all the time with choosing the page.

      I want to change section marker without going to that page.

      I wrote a script for that but script is corrupted and it changes the location of the page.

      My aim is to write page number  on script to change the section marker from that page

      How can I fix this?

       

      var w = new Window("dialog", "Section");
      var panel = w.add('panel', undefined, "----");
      var grup = panel.add('group', undefined, "");
      grup.orientation = "row";
      grup.add('statictext', undefined, "Page");
      var sayfa = grup.add('edittext', [0, 0, 50, 25], "1")
      grup.add('statictext', undefined, "Section Marker");
      sayfa.graphics.font = "Tahoma:16";
      var kisim_isaretcisi = grup.add('edittext', [0, 0, 50, 25], "A")
      kisim_isaretcisi.graphics.font = "Tahoma:16";
      kisim_isaretcisi.active = true;
      w.add('button', undefined, 'Tamam', {name: 'OK'}).onClick = function() {
      w.close(12345);
      }
      if(w.show() == 12345) {
      var doc = app.activeDocument; 
      var syf = Number(sayfa.text);
      var curSec = doc.pages.item(syf).appliedSection; 
      var name = curSec.name
      var ksm = kisim_isaretcisi.text;
      if(!syf){
      syf = i;
      }
      doc.sections.add({pageStart: doc.pages.item(syf-1), marker: ksm, name : name })
      }
      
        • 1. Re: Why does the page number change
          Wosven Level 1

          Hi,

           

          First thing, you shouldn't use "name" as a variable name, and I can't see where "i" is defined, so I modify those parts.

           

          Second, for keeping page number, you need to disable / enable again continueNumbering.

          I added : continueNumbering : false, pageNumberStart : syf

           

          var w = new Window("dialog", "Section");  
          var panel = w.add('panel', undefined, "----");  
          var grup = panel.add('group', undefined, "");  
              grup.orientation = "row";  
              grup.add('statictext', undefined, "Page");  
          var sayfa = grup.add('edittext', [0, 0, 50, 25], "1")  
              grup.add('statictext', undefined, "Section Marker");  
              sayfa.graphics.font = "Tahoma:16";  
          var kisim_isaretcisi = grup.add('edittext', [0, 0, 50, 25], "A")  
              kisim_isaretcisi.graphics.font = "Tahoma:16";  
              kisim_isaretcisi.active = true;  
          w.add('button', undefined, 'Tamam', {name: 'OK'}).onClick = function() {  
              w.close(12345);  
          }  
          if(w.show() == 12345) {  
              var doc = app.activeDocument;   
              var syf = Number(sayfa.text);  
              var curSec = doc.pages.item(syf).appliedSection;   
              var sName = curSec.name;
              var ksm = kisim_isaretcisi.text;  
              if(!syf){  
                  syf = 1; //i;  
              }
              var thisSection = doc.sections.add({pageStart: doc.pages.item(syf-1), marker: ksm, name : sName, continueNumbering : false, pageNumberStart : syf })  
              thisSection.continueNumbering = true;
          }
          
          • 2. Re: Why does the page number change
            hamdifem Level 1

            I created an 8 page document

            run script  page:1 section: A  (I write)

            result  pege 1-8 section A

            and again run scritp

            page: 4 section : B

            result  page 4-8 section B

            great no problem

             

            and then

            run scritp

            page: 4 section : C

            result  page 4-8 section B  (no change)

             

            and again run scritp

            page: 1  section : K

            result  page 1-4 section K  (changed)

             

            Total : Does not change the next pages

            • 3. Re: Why does the page number change
              Wosven Level 1

              That's because you change the section, while the script only apply a section.

              You need to modify the script for this case, or not to make errors when applying sections

              • 4. Re: Why does the page number change
                hamdifem Level 1

                I did modify but new error: This page already has another section

                 

                var sct = doc.sections.add(doc.pages.item(syf-1)); 

                sct.marker = ksm;

                 

                There is section marker on page

                How can i specify

                • 5. Re: Why does the page number change
                  Wosven Level 1

                  Sorry, I'm AFK and ID,

                  You'll have to check first if the page is the beginning of a section

                  (before "var thisSection = ...") :

                  if not : procede as before, ans add the section

                  else: try to change the section marker value

                   

                   

                  For the correct syntaxe, check on Jongware's site or Adobe documentation