Highlighted

How to check current page type

Advocate ,
Nov 30, 2017

Copy link to clipboard

Copied

"Welcome back my friends to the show that never ends" - I'm trying to handle variables and need to know whether the  current page is a master page or body page. As You know, on a master page more system variables are valid (Running H/F xx, Current Page #). So to set up a list of valid system vars I need to know where I am.

I read in the doc: PageObject is any Page object i.e., BodyPage, MasterPage, ReferencePage, HiddenPage.

Experiments show that I get answers with this short pgm - but what kind of pages are 'hidden' in the values 0...4, > 7 ?

Is this the correct way to test for the page type?

// CheckPageType.jsx
var   oDoc = app.ActiveDoc;
var   oPage = oDoc.CurrentPage;
var pageType = oPage.type;
$.writeln ("page = " + pageType);
/* type reported
   5   Constants.FO_BodyPage     
   6   Constants.FO_MasterPage
   7   Constants.FO_RefPage
*/

Ah well, "don't check for an error situation you don't know how to handle".

Klaus

Adobe Community Professional
Correct answer by frameexpert | Adobe Community Professional

Another way to check is like this:

#target framemaker

var doc = app.ActiveDoc;

var page = doc.CurrentPage;

alert (page.constructor.name);

This will return one of these strings: BodyPage, MasterPage, RefPage

TOPICS
Scripting

Views

212

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

How to check current page type

Advocate ,
Nov 30, 2017

Copy link to clipboard

Copied

"Welcome back my friends to the show that never ends" - I'm trying to handle variables and need to know whether the  current page is a master page or body page. As You know, on a master page more system variables are valid (Running H/F xx, Current Page #). So to set up a list of valid system vars I need to know where I am.

I read in the doc: PageObject is any Page object i.e., BodyPage, MasterPage, ReferencePage, HiddenPage.

Experiments show that I get answers with this short pgm - but what kind of pages are 'hidden' in the values 0...4, > 7 ?

Is this the correct way to test for the page type?

// CheckPageType.jsx
var   oDoc = app.ActiveDoc;
var   oPage = oDoc.CurrentPage;
var pageType = oPage.type;
$.writeln ("page = " + pageType);
/* type reported
   5   Constants.FO_BodyPage     
   6   Constants.FO_MasterPage
   7   Constants.FO_RefPage
*/

Ah well, "don't check for an error situation you don't know how to handle".

Klaus

Adobe Community Professional
Correct answer by frameexpert | Adobe Community Professional

Another way to check is like this:

#target framemaker

var doc = app.ActiveDoc;

var page = doc.CurrentPage;

alert (page.constructor.name);

This will return one of these strings: BodyPage, MasterPage, RefPage

TOPICS
Scripting

Views

213

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 30, 2017 0
Enthusiast ,
Nov 30, 2017

Copy link to clipboard

Copied

Klaus,

I don't think that the oDoc.CurrentPage can ever be a HiddenPage because you can't interact with them directly.

When I work with the various page types I normally get the page's Object type using instanceof, it seems to be more reliable. I use it like this:

var   oDoc = app.ActiveDoc; 

var   oPage = oDoc.CurrentPage; 

var pageType = oPage.type; 

if (oPage instanceof BodyPage) {

    $.writeln ("This is a Body Page");

    }

I hope that helps?

Ian

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 30, 2017 0
Adobe Community Professional ,
Nov 30, 2017

Copy link to clipboard

Copied

Another way to check is like this:

#target framemaker

var doc = app.ActiveDoc;

var page = doc.CurrentPage;

alert (page.constructor.name);

This will return one of these strings: BodyPage, MasterPage, RefPage

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 30, 2017 0