Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Previous section Next section Previous page Next page Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Page 2 of 2
Topic:
Create a jump in prontoscript
This thread has 27 replies. Displaying posts 16 through 28.
Post 16 made on Saturday May 17, 2008 at 11:01
jacovn
Long Time Member
Joined:
Posts:
December 2007
33
On May 17, 2008 at 08:07, Lyndel McGee said...
| Most of the script you write will be in the Activity Script.
Rest is in PageUp/PageDown Hard Key button scripts.

Ok, so i would write in the page-up hardkey only the call to the function like:

pagenumber++;
scheduleAfter(10, jumpto(pagenumber));


And on the activity level definde the actual function to make the page jump.

var jumppages = new array[];
var pagenumber = 0;

jumppages[0] = CF.widget("jump1", "hiddenpage", "mainactivity");
jumppages[1] = CF.widget("jump2", "hiddenpage", "mainactivity");
jumppages[2] = CF.widget("jump3", "hiddenpage", "mainactivity");


function jumpto(whichpage)
{
jumppages[whichpage].executeActions;
}


I think i start to understand why after reading this thread: [Link: remotecentral.com]

So it would be best to have only some basic switch statements etc. on the page level, and let them call the functions on activity level to avoid them getting reinitialized and defined every 100 milisec.


Unfortunately this example does not work as on the hardbuttons the variables defined in the activity are unknown. I get: ReferenceError: pagenumber is not defined

I guess this is again a stupid problem, but i do not see it. I have read chapter 6 and 7 of the Developers guide once more. as my pages are under the activity, the variables set should be visable on all the pages under that activity.
Doe the hard-key's in the activity not fall into the same scope ?

Last edited by jacovn on May 17, 2008 11:43.
Post 17 made on Saturday May 17, 2008 at 12:14
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,007
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.
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 18 made on Saturday May 17, 2008 at 13:15
jacovn
Long Time Member
Joined:
Posts:
December 2007
33
Thanks,

[quote]
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.
[/quote]

I did this in the same activity. I started a new config, made one device (my activity) and added 4 pages, made one hidden (named: hiddenpage) with 3 buttons (jump1, jump2 and jump3) on it with a normal jump action to the other 3 pages (named page1, page2 and page3)

In the property's of the device i had the following:

var pagenumber = 0;
var jumppages = new array[];
jumppages[0] = CF.widget("jump1", "hiddenpage", "mainactivity");
jumppages[1] = CF.widget("jump2", "hiddenpage", "mainactivity");
jumppages[2] = CF.widget("jump3", "hiddenpage", "mainactivity");
function jumpto(whichpage)
{
jumppages[whichpage].executeActions;
}

The hardkeys page-up and page-down i also did in the same propertys of the device as the above code is in. So thats why i thought i did it in the right scope.


I changed the function to your function and the hardkey script also, but get the same error (have a _PS_DEBUG_ panel on my page1, page2 and page3)
It does complain on the variabele pagenumber: "ProntoScript Error: ReferenceError: pagenumber is not defined Offending sctip: (untagged)"

According to the flanagan book (i bought it in the meanwhile) pagenumber is not a reserved word.

[quote]
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.
[/quote]

I did realise that, but left that out to first see if i could jump from page 1 to page 2 and 3. I understand i would get an exception if i tried a indexnumer from the array without data.


[quote]
This is user error, not Pronto Error. I know many don't like to hear this but it is usually the case.
[/quote]

I am certain it is user error in my case. It is no problem to say that to me. I am here to learn.
Post 19 made on Saturday May 17, 2008 at 14:08
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,007
If you want to email me a stripped-down config with ONLY the activity in question, I will have a look.

I will make recommendations based on what I see there.

My addy is on profile.
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 20 made on Saturday May 17, 2008 at 15:48
jacovn
Long Time Member
Joined:
Posts:
December 2007
33
i did sent you the file, thanks.
Post 21 made on Saturday May 17, 2008 at 19:35
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,007
You've got mail. You missed tagging page and jump buttons. Your activity has incorrect prontoname "main" and you have a syntax error declaring your array. This caused the activity to not initialize which means your pagenumber variable is never declared in the activity scope.

// The following line causes error which prevents activity from initializing properly. When this occurs, the pagenumber variable is never declared.


var jumppages = new array[];

should be either:

var jumppages = [];

or

var jumppages = new Array();
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 22 made on Sunday May 18, 2008 at 00:19
jacovn
Long Time Member
Joined:
Posts:
December 2007
33
Like i wrote you back already, i must perhaps request my school money back..
thanks..
Post 23 made on Sunday May 18, 2008 at 00:28
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,007
I've had this same exact problem happen to me on occasion. Things should work but they don't. Variable are defined but they are NOT.

Here's how I solve this problem.

At the end of the activity or page script, I log to the diagnostics log.

For example:
// at start of script.
Diagnostics.log('initiating activity script');

// at end of script.
Diagnostics.log('completed activity script');


Then, as I continue onward and something does not work, I look at the diagnostics log.

Barry Gordon frequently uses the Page vs Activity script and he has another clever solution.

He puts a widget in the system area of the page that is red with with text that says "Error". At the end of his page script, he simply does GUI.widget('Error').visible = false;

This way, when he loads up a page if the widget is visible, something went wrong.

We all have different ways of debugging. To each his own. However, finding this problem where a script does not initialize as expected is a royal pain.

Here's another solution that I sometimes use.

var x;

try
{
// do anything you need to do inside this block. Note that x is declared outside but not assigned.

}
catch(e)
{
Diagnostics.log('error: ' + e);
}

I frequently use the diagnostic log versus System.print simply because I do much of my scripting in the Activity Script and using eval(widget.label). When you encounter problems during activity initialization, PS_DEBUG is somewhat useless. However, let it be known that if you do the base mod for the 9600 and use System.setDebugMask(9), System.print() comes in very handy.
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 24 made on Sunday May 18, 2008 at 02:27
jacovn
Long Time Member
Joined:
Posts:
December 2007
33
I also looked if i could find a on-line javascipt checker.
one is http://www.jslint.com/ and that sort of works.
It at least find my dumb mistakes.

But it also complains about things the 9600 has no problems with:

Problem at line 9 character 21: Use the array literal notation [].
var jumppages = new Array();
Post 25 made on Sunday May 18, 2008 at 04:21
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,007
You should investigate the options file that ships with the product. I use JSLint in MS Visual Studio as an external tool to check all my stuff.
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 26 made on Sunday May 18, 2008 at 15:58
jacovn
Long Time Member
Joined:
Posts:
December 2007
33
I works ok now.
I can see some error lines when the page jumps over, but cannot read them since they dissapear since the new page is built up i guess.
Post 27 made on Sunday May 18, 2008 at 16:10
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,007
The error that you are seeing is 100% normal. This is an "Actionlist Error" that is simply logged indicating that the actionlist is terminating due to a page jump.

You cannot trap this error. If you had the base-station mod and were using System.setDebugMask(9), you'd be able to see this on the PC screen.

Personally, I've asked Philips to try and do away with the error. I can't recall if this message shows up in the Diagnostics log. I think it may and that's why I asked that it be removed. There is no reason to fill up the diagnostic log with a false error that is expected as the actionlist is being cancelled by a jump.
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 28 made on Sunday May 18, 2008 at 16:56
Barry Gordon
Founding Member
Joined:
Posts:
August 2001
2,157
For the reasons stated above there is an option in the debug system that goes with the Base station mod that drops those messages from the PC display screen but does write them to its internal log file.
Page 2 of 2


Jump to


Protected Feature Before you can reply to a message...
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now.

Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.

Hosting Services by ipHouse