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