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

Login:
Pass:
 
 

Original thread:
Post 2 made on Sunday December 3, 2017 at 18:05
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,992
Martin, Look closely at what you are doing....


page("PS_OVERLAY").onOverlayShow = function()
{
function xX()
{
CF.activity().label = null;
scheduleAfter(2000, aPIC ) ;
}

function aPIC ()
{
CF.activity().label = "Lights Control";
scheduleAfter(2000, xX ); // Animate
}

function bPIC ()
{
scheduleAfter(500, aPIC ) ; // Start Blink
}

bPIC () ;
}


The behavior you describe is exactly what you coded the script to do.

When the overlay is shown, you are calling bPIC().

inside bPIC(), you schedule call to aPIC() after 500 milliseconds.

inside aPIC(), you schedule call to xX() after 2000 milliseconds.

when xX() is called you again schedule a call to aPIC() after 2000 milliseconds. (which will result in xX() call being scheduled over and over)

So, what you have here is a continuously scheduled loop.

If you'd like to see what is really happening, put System.print() statements right before each scheduleAfter call indicating you are scheduling and then a System.print statement right after each function begins execution. I posted a thread a few years back about debugging pronto script where I suggest using try/catch blocks and System.print, etc...

Unfortunately, there is no way cancel a scheduleAfter task once it has been submitted (a cancellable 'handle' is not returned). However, you must break the repeating/recursive scheduleAfter cycle you have introduced.

One way to fix this is to add a variable named doAnimation and only issue the scheduleAfter if it is true.

See below. This should fix you issue.


var doAnimation = false;
page("PS_OVERLAY").onOverlayShow = function()
{
function xX()
{
CF.activity().label = null;
if (doAnimation)
{

scheduleAfter(2000, aPIC ) ;
}
}

function aPIC ()
{
CF.activity().label = "Lights Control";
if (doAnimation)
{

scheduleAfter(2000, xX ); // Animate
}
}

function bPIC ()
{
doAnimation = true;
// This if check not needed but added for completness as bPic only called 1 time

if (doAnimation)
{

scheduleAfter(500, aPIC ) ; // Start Blink
}
}

bPIC () ;
}

page("PS_OVERLAY").onOverlayHide = function()
{
CF.activity().label = null;
doAnimation = false;
}
this.scheduleActions();

Lyndel McGee
Philips Pronto Addict/Beta Tester


Hosting Services by ipHouse