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

Login:
Pass:
 
 

Topic:
script question
This thread has 3 replies. Displaying all posts.
Post 1 made on Monday March 30, 2020 at 15:17
Fischi
Long Time Member
Joined:
Posts:
January 2011
114
Hi, I've tried several timers like as described in the dev.guide.
I have a page timer with a panel showing the remaining time in seconds.
The page script is:

var w, hallLightsTimer;
w = widget("REMAINING");
w.label = hallLightsTimer ;

if( hallLightsTimer > 0 )
{
hallLightsTimer--;
if( hallLightsTimer == 0 )
page("IRCODES").widget("HALL_LIGHTS_OFF").executeActions();
}


All is running OK but after a jump to this page the label of the panel is "undefined"
After starting the timer the remaining time counts OK eg. from 10 to 0.
The 0 is staying.
"Undefined" occurs only after a page jump.
What's the reason ?

Regards,
Fischi
OP | Post 2 made on Wednesday April 1, 2020 at 12:30
Fischi
Long Time Member
Joined:
Posts:
January 2011
114
I‘ve solved it :

var w, hallLightsTimer;
w = widget("REMAINING");
w.label = hallLightsTimer ;
if (hallLightsTimer === undefined) {w.label == "-";}

if( hallLightsTimer > 0 )
{
hallLightsTimer--;
if( hallLightsTimer == 0 )
page("IRCODES").widget("HALL_LIGHTS_OFF").executeActions();
}

It looks a little bit nicer than „undefined“
Post 3 made on Wednesday April 1, 2020 at 19:00
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,992
You really did not fix it if you used "==" in
{w.label == "_";}
the above statement is actually not an assignment to the label but instead just evaluating the condition which reports true if the label of the widget matches "-"

Hoping this is just copy/paste or retype error on your part.


A better approach along to set the label to "-" if timer is not numeric is:

if (isNaN(hallLightsTimer)) {w.label ="-";}

[Link: w3schools.com]
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 4 made on Thursday April 2, 2020 at 05:25
Fischi
Long Time Member
Joined:
Posts:
January 2011
114
On April 1, 2020 at 19:00, Lyndel McGee said...
You really did not fix it if you used "==" in
{w.label == "_";}
the above statement is actually not an assignment to the label but instead just evaluating the condition which reports true if the label of the widget matches "-"

Hoping this is just copy/paste or retype error on your part.

A better approach along to set the label to "-" if timer is not numeric is:

if (isNaN(hallLightsTimer)) {w.label ="-";}

[Link: w3schools.com]

Thanks Lyndel for the tip with isNaN.
I learned something again !

{w.label == "-";} ... it was a copy and paste mistake
{w.label = "-";} is right!

Regards, Fischi

Last edited by Fischi on April 2, 2020 11:25.


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