Just starting to use scripts - please advise

Forum to discuss MLScript plugin that enables VBScript and JavaScript scripting within MLServer3.
User avatar
simonmason
Expert
Expert
Posts: 855
Joined: Tue Dec 26, 2006 9:06 pm
Contact:

Just starting to use scripts - please advise

Postby simonmason » Sat Nov 29, 2008 9:01 am

First question - when I use the Log command what level of logging do I need to have the server set in order to see the log commands?

Second, I am starting to write a script (below) and I am apparently having trouble calling it. I am calling this with the command: MLScript|Audio.ZoneSelectSource~ ZoneNextSource~1

Shouldn't I be seeing the variable AAATest2 updated and also some entries in the log?

Thanks for the help.



Code: Select all

Option Explicit

' MLServer Command Reference
'  MLServer.cmdReceive command - allows you to send MLServeCmd's back to the server
'  MLServer.cmdReceivePush command - allows you to push a MLServeCmd onto the MLServer command queue
'  MLServer.SetVariable variable, value - allows you to set MLServer variables
'  MLServer.GetVariable variable - allows you to get the value of the specified MLServer variable
'  MLServer.DelVariable variable, value - allows you to delete MLServer variables
'  MLServer.LogMLEvent sName, sEvent - allows you to add an entry in the MLServer Event Log
'  MLServer.doPlugin PluginName, PluginCommand, PluginParameters, ClientName


Sub ZoneNextSource (Params)
' Param one is zone number
Dim ZoneSource

MLServer.LogMLEvent "HOMESEER", "Entered Subroutine"

MLServer.SetVariable "AAATest2", "Params : " & Params(0)
If Ubound(Params) = 1 then
   MLServer.SetVariable "AAATest2", "Params : " & Params(0) & " - Started"
   ZoneSource = MLServer.GetVariable(mlhsplugin_n17)
   MLServer.SetVariable "AAATest2", ZoneSource
   if ZoneSource = "CHA3" then
      MLServer.SetVariable "AAATest2", "Params : " & Params(0) & " - Found CHA3"
   End if
End if

End Sub

MLServer.LogMLEvent "HOMESEER", "Entered Script"
Simon D. S. Mason

mwebster
Intermediate
Intermediate
Posts: 271
Joined: Mon Mar 20, 2006 10:38 pm
Contact:

Postby mwebster » Sat Nov 29, 2008 8:31 pm

Not sure that it's still there, but there used to be a checkbox in the mlserver options menu that enabled/disabled scripts. Might check that if you haven't already.

User avatar
simonmason
Expert
Expert
Posts: 855
Joined: Tue Dec 26, 2006 9:06 pm
Contact:

Postby simonmason » Sun Nov 30, 2008 8:48 am

I have the plugin enabled. I am starting to figure it out. So far I cannot seem to get any error messages to display in the log. The script was failing on the line:

Code: Select all

  ZoneSource = MLServer.GetVariable(mlhsplugin_n17)


and nothing after this line was executing. This was because I didn't follow the correct syntax, enclosing the variable name in quotes. How did I figure this out? Trial and error, placing a server log command at each line in the code until I figured out where it is stalling.

The test button on the script did not uncover this error. Some advice on the server log would be appreciated. Is it possible to get it to display script errors or abnormal termination of a script? Thanks.
Simon D. S. Mason

User avatar
CinemarDave
Site Admin
Site Admin
Posts: 10535
Joined: Fri Feb 07, 2003 8:56 am
Location: Planet Earth
Contact:

Postby CinemarDave » Sun Nov 30, 2008 10:43 am

There's a syntax error on the line. You are missing the quotes.

ZoneSource = MLServer.GetVariable("mlhsplugin_n17")

Without the quotes the script would think that the variable is a local variable and since it was not defined it will throw an error.

User avatar
simonmason
Expert
Expert
Posts: 855
Joined: Tue Dec 26, 2006 9:06 pm
Contact:

Postby simonmason » Sun Nov 30, 2008 12:03 pm

Thanks, I figured out the syntax error. What I haven't figured out is how to get the system to let me know there was an error. The test button didn't catch it and I can't figure out how to get a script error to show in the server log. All logging settings don't seem to show script errors?
Simon D. S. Mason

ricks
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1127
Joined: Wed Oct 27, 2004 7:01 pm
Location: Latham, Massachusetts
Contact:

Postby ricks » Sun Nov 30, 2008 12:09 pm

Yes, that was something I found a while ago. Would also be nice if "cut and paste" worked in the script window.

User avatar
simonmason
Expert
Expert
Posts: 855
Joined: Tue Dec 26, 2006 9:06 pm
Contact:

Postby simonmason » Sun Nov 30, 2008 12:14 pm

While we are adding ideas - how about the ability to launch an external editor?
Simon D. S. Mason

User avatar
CinemarDave
Site Admin
Site Admin
Posts: 10535
Joined: Fri Feb 07, 2003 8:56 am
Location: Planet Earth
Contact:

Postby CinemarDave » Sun Nov 30, 2008 4:21 pm

Cut and Paste does work. Ctrl-C and Ctrl-V will work.

Other options are already on the list of enhancements.


Return to “MLScript”

Who is online

Users browsing this forum: No registered users and 1 guest