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:
[PS] macros and ProntoScript
This thread has 9 replies. Displaying all posts.
Post 1 made on Sunday September 16, 2007 at 15:49
Marc-Etienne HUNEAU
Long Time Member
Joined:
Posts:
August 2007
80
Don't get me wrong : I love ProntoScript.

That said, I'm having trouble doing what I want.

Let me write down what I think I understood :

- ProntoScript is a great tool for RS232 and TCP (bi-)directional stuff.

- It's easy from PS to trigger a button's list action, thus allowing for conditional IR.

- the TSU cannot execute a script AND a macro at the same time.

Now, questions :

- when calling executeActions(), if the widget contains a script, is it executed ?

- if so, is the calling script resumed when the called script returns ?

- when the actions are a macro, is the script resumed when executeactions() returns, or is it stopped ?

- Since there's no way to declare a global function (or is there ?), what if I want to call a script from another activity ?

- last case : a macro calls a button containing a script : is the macro dropped and the script executed, or is the script skipped ?
--
Marc-Etienne HUNEAU
http://www.dsr.fr
Post 2 made on Sunday September 16, 2007 at 22:22
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,994
Mark, answers below.

1. executeActions() does not execute any script, only an actionlist of a button. This should provide the base answer for several of your other questions. ie last case.

2. if the actionlist contains a jump that causes you to leave the page you are on, your script will be ended. See Jump To Another Activity and Multiple Jumps... on Page 32 of the PS Dev Guide.

3. The only way to declare a global script is by faking it. Use system.setGlobal() to save contents of a common script such that you can eval(System.getGlobal('myscript')); in another activity. This kinda-sorta defeats the purpose because you can eval contents of any widget in your activity. Therefore, I suggest something like defining a 'Resources' activity and then putting a 'Scripts' page in this activity with panels where the label contains commonly used scripts.

I have not tried this but you might be able to 'decorate' global Javascript objects such as 'Object' or 'String' by doing something like...

Object.prototype.myfunction = function(param1)
{
System.print(String(param1));
}

What I'm unsure of at this point is whether the scripting engine is reinitialized upon entry into each activity.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 3 made on Monday September 17, 2007 at 14:52
Marc-Etienne HUNEAU
Long Time Member
Joined:
Posts:
August 2007
80
I'm beginning to see the light.

So... if I want to call a button's script, I should write :

w = CF.widget("ButtonTag", "PageTag" [,"ActivityTag] );

eval(w);

then, if I want the actionlist to be fired too :

w.executeActions();

right ?

The way ProntoEdit UI works, I thought a button could not execute both an actionlist AND a script.
If there's a script, I guess the actionList is only executed if executeActions() is called, right ?


Now, what I would LOVE to see in the next version of prontoscript, is a way to enumerate the widgets on a page.
Because : with my crestron stuff in mind, if I want to provide feedback the crestron way, I tag the objects (like D1 to Dxx for digital joins, A1 to Ayy for analog values, and S1 to Szz for strings). Now, when a page is initialized, I'd want to check all the widgets on the page and store their IDs so as to be able to dispatch feedback messages.

I guess if I use a for.. statement counting to 1024 (for instance) to try all the widgets tagged D1 to D1024 (catching the errors) it's gonna take tons of time.
--
Marc-Etienne HUNEAU
http://www.dsr.fr
OP | Post 4 made on Monday September 17, 2007 at 16:04
Marc-Etienne HUNEAU
Long Time Member
Joined:
Posts:
August 2007
80
Oh, no !

Now I got it : eval() works with a script code. Not a script ref.
--
Marc-Etienne HUNEAU
http://www.dsr.fr
Post 5 made on Monday September 17, 2007 at 22:18
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,994
eval() works on a text string, ie a widget (Panel) label and not on the button itself.
Your example above is just evaluating the widget which is equivalent to eval(String(w)) with with String(w) is an empty string.

You can only execute script in a button by pressing it. Philips has stated that buttons with script cannot also execute their actions although I found it possible in certain cases.

For more info on eval(), see:

[Link: articles.techrepublic.com.com]

[Link: developer.mozilla.org]

I personally put javascript classes into Panel Labels and use eval(labelcontents) to define the classes. Makes for encapsulation and modularization plus it keeps your scripts from getting all wrapped up together.

Notice that I did not do this with Galaxy or Pong but I could have easily done that, especially with Pong.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 6 made on Tuesday September 18, 2007 at 17:10
Marc-Etienne HUNEAU
Long Time Member
Joined:
Posts:
August 2007
80
calling executeActions() at the end of the button script... executes the actions. And raises an error if there's a jump to another activity. But who cares : it does jump ! :-)
--
Marc-Etienne HUNEAU
http://www.dsr.fr
Post 7 made on Tuesday September 18, 2007 at 19:51
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,994
Marc,

FYI, this is an undocumented "feature". Yes, I know it works today but it may not work in the future. Specifically, during the Beta test, I raised the fact that an error is thrown and was told that my use case was one that they had not considered. Specifically, I was doing some scripting in the 'Home' hard button to clean up some things then executing the jump in the action list.

Currently, a button can do both things simply by calling this.executeActions() but may not be able to do this in the future.

Lyndel
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 8 made on Friday September 21, 2007 at 06:13
Marc-Etienne HUNEAU
Long Time Member
Joined:
Posts:
August 2007
80
Pity, it's a wonderful undocumented feature.
--
Marc-Etienne HUNEAU
http://www.dsr.fr
Post 9 made on Friday September 21, 2007 at 07:34
Barry Gordon
Founding Member
Joined:
Posts:
August 2001
2,157
That error is raised any time you executeActions and the action breaks the current script (jumps) . Philips' rationale was it is merely a warning that the current script has ended. As I always say, "If you can's fix it, feature it". They should at least clean up the error message to make it not sound like an error (I think Action List Error is what they say)
Post 10 made on Saturday September 22, 2007 at 02:33
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,994
Yep, that's the message.
Lyndel McGee
Philips Pronto Addict/Beta Tester


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