Prerelease is a good idea (if you are happy donating hours of your time
One way to prevent these issues, though, is simply to target your script
version explicitly at the beginning of every script:
If you include that at the start of each script, even if your users
upgrade, the script should normally still work.
Have you tried that? Perhaps it doesn't work for things that are
dependent on InDesign's implementation (e.g., where the page is added)
mlavie — yes, being member of the prerelease would help. A bit.
But that also means, testing every extension against the latest build that will be released to its members. Always.
Or you have to wait until the builds are feature closed a couple of weeks before final release and do intensive testing then.
Scripting documentation is sparse. There will be no notification, automated, half automated or not-at-all automated.
You have to find out yourself what's different in old methods or if new properties or methods will come along with old and new features and possibly break or support your workflow in new ways.
Thank you for sharing your findings about method add() for the pages class.
I cannot confirm your findings with my current versions of CS6 (v8.1.0), CC (v9.3.0) and CC-2014 (v10.2.0). I cannot see, that pages are added not at the end of the document.
Equal of what spread or page is the active one. Also equal if a page item is selected or not (OSX 10.7.5). Your versions will tell a different story. I will and cannot question this.
Just to assist you in this particular problem:
As I can see from documentation, there are three arguments in method add() where you can determine where exactly you are adding a new page.
Use these and to be on the safe side. The first one is the location option. If you are using LocationOptions.AT_END the new page will be added as last page in the document. And this argument is available (I think) in InDesign CS3 to CC-2014.2.
To make your added page the active one should be easy as well:
var myAddedPage = app.documents.pages.add(LocationOptions.AT_END); app.documents.layoutWindows.activePage = myAddedPage;
I know, the problem is always to anticipate what could break in a new released version and do a test, if the method or feature of a script is showing the expected results. In your case the test, if the added page has the highest documentOffset value of all pages and if the active page of layoutWindows has the same documentOffset value as the added page.
Sometimes we simply do wrong assumptions.
That's the way it is…
Another example of a false assumption:
Method duplicate() of the pageItems class.
Assumption: "The duplicated object is always on the same x/y position as the original page item."
True in most cases, but wrong if we consider all cases and you never duplicated anchored objects which never came to your mind since the feature is not available in the "normal" UI; it is grayed out, if you select an anchored object.
Try duplicate() on an anchored pageItem and test the result.
You'll see, that the duplicate of an anchored object is moved as well.
Is this a bug? Is this as designed? Who can tell? The method was created long ago and you cannot ask the developer who was responsible for implementing it, because his/her name might be never documented or he/she possibly has left Adobe long ago (all speculations).