I have the following problem. I have a script on PageOpen, and it should only passed through once. I have found the following method, to solve this problem, when I first open the form:
var PageOpen = 0
if(PageOpen < 1)
{
PageOpen++
my script...
}
But this works only for the first time. When I save the document, and invoke the document later, the script run is passing through, for another time. How can I solve this problem. I thought on save the content of the variable, but I don`t no, how to manage this.
Keep in mind that this saves the variable in your folder level JS glob.js file and there is a 32K limit for all such variables. Also keep in mind that this is a "Local" state - someone opening the PDF elsewhere will not have the same folder level js. Anyway, that is how I understand it - I only use such in a "local" setting.
Hope this helps with your Global question.
Lee C
if (typeof global.pageOpen == "undefined") global.pageOpen = 0;
if (global.pageOpen == 0) {
your script...
}
global.pageOpen++;
global.setPersistent("pageOpen", true);
Tobias
var PageOpen = 0
if(PageOpen < 1)
{
PageOpen++
my script...
}
To make it work like you want, it should be:
// Will initialize to 0
var PageOpen;
if(PageOpen < 1)
{
PageOpen++
my script...
}
When this code is first hit, the variable "PageOpen" will be given a value of 0, or false. Your code then sets it to 1, or true. The next time the code is hit, PageOpen will be equal to 1. Since your code was resetting PageOpen to 0 each time, it doesn't have the desired effect.
I do this a bit differently, by explicitly setting the value in a document-level routine which runs when the PDF is opened. Something like:
var PageOpen = false;
The code would then be:
if(PageOpen < 1)
{
PageOpen = true;
my script...
}
George