Part of the problem is you don't fully understand how scheduleAfter() works.
It takes 2 or more parameters....
Param 1. Millisecond time (must be > 0)
Param 2. Function previously defined or inline declared that will be executed.
Param 3. Optional First parameter to pass to function when invoked.
Param 4. Second parameter to pass... and so on.
You have:
scheduleAfter(10, jumpto(pagenumber));
which only defines the time and a function(). However, I suspect that when the function is called, pagenumber is out of scope because there is no current activity. That's why you are suspecting that scopes don't work. You are missing the parameter to pass in to the function. What I have defined below should work.
You can use a direct call as you suggest but I would recommend using CF.activity().scheduleAfter() to do this.
function jumpto(whichpage)
{
if (jumppages[whichpage])
CF.activity().scheduleAfter(5,function (w){w.executeActions();},jumppages[whichpage]);
}
This way, in a page script, you could also call the function if you needed to.
Then, in your hard key script...
pageNumber++;
jumpto(pagenumber);
Note that you HAVE A PROBLEM with this. What happens when you reach the end of the array? You have not written code to set the index back to 0.
With regard to variable scoping, the activity variables should be visible to the Hard Buttons in the current activity. You mention that you defined script for Hard Button Page Up. Where did you define this script? Home, target activity, or on System Page? It should be in the target activity where you coded page script above.
This is also a case where I am flying blind. You should use Diagnostics.log and try/catch to see where your real problem is if the above does not work. This is user error, not Pronto Error. I know many don't like to hear this but it is usually the case. I, too have errors every now and then that usually turn out to be stupid mistakes. Sometime I spend 3-4 hours trying to find them.
Good luck.
Last edited by Lyndel McGee
on May 17, 2008 12:26.