Skip to main content
hamdifem
Inspiring
December 17, 2016
Question

Why does the page number change

  • December 17, 2016
  • 1 reply
  • 795 views

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 })

}

This topic has been closed for replies.

1 reply

Wosven
Participating Frequently
December 18, 2016

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;

}

hamdifem
hamdifemAuthor
Inspiring
December 18, 2016

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

Wosven
Participating Frequently
December 18, 2016

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