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:
Still problems with PEP2 / shared scripts
This thread has 3 replies. Displaying all posts.
Post 1 made on Tuesday December 30, 2008 at 06:01
flattermann
Long Time Member
Joined:
Posts:
December 2008
16
Hi guys!

First, I'd like to express my thankfullness for this page! It already helped me really much, but now I have a problem that I can't solve on my own:

I'm currently learning how to do fancy things with ProntoScript on my Pronto 9400. :-) Because it is my first Pronto, I began my project in PEP2. (Well I tried PEP1.1 a bit, but the ProntoScript supporting Simulator of PEP2 convinced me of the latest PEP version.)

Most of the things are working pretty well and my first ProntoScript component (a PS generated radio station list with scroll wheel support) is running. :-)

Now, I'd like to use some kind of "Shared ProntoScript Library", i.e. I would like to put all PS code there, that will be invoked from multiple locations/activities.

Example:
I'd like to create a shared macro "Switch to Source X" that checks the global variables (containing the power states and input settings of all devices) and executes all appropriate actions.

I've already read many forum threads here, and I thought that it should work this way in PEP2:

- I've created an activity named "aLib" with a page "pPage" and a button "wButton"
- I attached the PS Code 'System.print("Hello World!");' to the button
- If I press this button manually, the Simulator dumps the "Hello World" string, as expected
- Now I thought that I could call the PS code of this button by calling 'CF.widget("wButton", "pPage", "aLib").executeActions()' in another activity

I've tried this PS call ('CF.widget...') in an page PS code and in a button PS code, but the Simulator does not tell me anything (not even an error message).

Do you have any ideas why this does not work?

Thanks a lot and have a happy new year 2009!

Last edited by flattermann on December 30, 2008 06:08.
Post 2 made on Tuesday December 30, 2008 at 16:58
GuerillaBuild
Long Time Member
Joined:
Posts:
December 2008
79
Hi flattermann,
it sounds like you are looking for a generic storage area where you can call and execute ProntoScript code from. There are some potential challenges doing this from one activity to another as the in memory copy of the script disposes of itself as soon as you leave the activity. Depending on what you are doing with the code you may be able to get some cross-activity scripting going. You will have to be careful with variable declarations and in some cases you may want to experiment with the global variables.... Albeit they are not exactly the most popular choice.
intro blurb over and done with. Here's a method that some of the other members use that you might find helpful:


There is a javascript method that is supported under ProntoScript called eval(). Eval basically executes whatever string you feed it as an executable line of code. The only caveat is that the string must contain a valid and properly formatted load of javascript code in it.

Example: If you put the line System.print("Hello World"); in the text window (label) of the button widget, and then from either another button or your page script use the following command: eval(CF.widget("Button","Page").label);

What Happens: when the eval method is executed, it retrieves the text string from the widget / button and executes it as javascript.

Technically: You could store a dump truck load of panels, buttons or whatever turns your crank on a hidden page and store different javascript code blocks in each one based on purpose.

PS: Regarding the simulator: it's great for running tests on non-prontoscript areas, but it is not as robust as we would all like it to be and quite honestly based on all the configuration options and methods that could be delpoyed it's not that feasible. Unless you want to try out hot-wiring your pronto with some mods, load the config and test with the Debug panel!

Hope this helps you

Cheers // Jason
You can hide almost anything until you have to put the drywall up!
Post 3 made on Wednesday December 31, 2008 at 12:09
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,006
If using PEPV2, just make sure that the Panel containing script has a Font Size other than ZERO/NONE. If you do not do this, then during the download process, the script you put into the label will be removed as part of memory optimization.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 4 made on Tuesday January 6, 2009 at 17:18
flattermann
Long Time Member
Joined:
Posts:
December 2008
16
Thanks a lot for your help, Jason & Lyndel!

I've put my shared library into a panel.label now and load it using eval(). The solution is not so clean as I hoped, but much better than copying the shared lib into every activity... :-)

Another question:
Is it correct that I need a button for every IR code that I like to send? AFAIK, it's not possible to send an IR code directly from ProntoScript, instead I have to add a button with the IR command in it's action list and then run it via widget().executeActions().

BTW: I already love ProntoScript! I think, using JavaScript as base was a brilliant idea from Philips. Ok, they could improve/expand the PS API a bit to make the developer's life easier, but even with the current API, the possibilities are great! I already have so many ideas what I could do with the Pronto, I only need more time... :-)


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