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 4 made on Saturday February 18, 2023 at 01:05
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
Note that I edited the response below to hopefully make the explanation more cohesive.

What's wrong with the script? User error! ;-)

You only defined functions in your Global Library with the exception of a single call to your time() function. To your point, a Global Library does execute each time you change activities, however, when your library is compiled, the code only calls time(); (see below)

var seconds = new Date().getSeconds();
}
time()

As this is the case, no timers are started by the invocation of the Global Library.

Note that you stated to get the recurring timer started first time through, you pressed a button with script that called periodicUpdate_2(CF.activity()).

Exercise to see how pressing button 10 times will eventually cause an error - If you press that button more than 1 time as each time you do, you create yet another timer. I bet if you press it more than 10 or 20 times, you'd see an error as there is a limit to the number of timers Pronto can have (see Dev Guide notes on scheduleAfter).

That single press of your button is good only while in the current activity as when activity changes, even though a script may be defined as a global library, the entire Javascript stack is blown away (see Dev Guide about Scopes - System Activity, Page, Button). Any variables, etc. from a Global Library go away each time an activity changes.

Think of a Global Library as just a placeholder for common scripts (added by PEP2 developers to make things a bit easier) that a user can choose to include (check box) for activities rather than having to add JS file to each activity.

In order to restart your timer for every activity, you'd need to have the Global Library both define and call the periodicUpdate_2 function.

From what I'm seeing above, modify your library to add the 2 lines below to the end. Note that you might also want to remove the cited call above to time().

// Kick off new timer for the current activity.
periodicUpdate_2(CF.activity());

Last edited by Lyndel McGee on February 18, 2023 12:23.
Lyndel McGee
Philips Pronto Addict/Beta Tester


Hosting Services by ipHouse