Trouble with MLServer.LogMLEvent

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:

Trouble with MLServer.LogMLEvent

Postby simonmason » Tue Dec 23, 2008 7:05 pm

I cannot get this command to work in the log? I have tried everything and it does not write to the log. Are there any known issues with this command? Thanks.
Simon D. S. Mason

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

Postby simonmason » Tue Dec 23, 2008 7:48 pm

I don't know if this is related but when I click on the test button for the sample script Sample1 I get an error 13 - Type mismatch: 'MLServer.LogMLEvent'?
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 » Tue Dec 23, 2008 9:39 pm

Add a third paramter of ,0 to the command. By default LogMLEvent assumes info logging. If you want the message to always appears set the value to 0 and it will show up regardless of logging level.

MLServer.LogMLEvent Module, Event, 0

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

Postby simonmason » Wed Dec 24, 2008 7:42 am

That didn't appear to work. I had tried changing the logging level on the server thinking that this might be an issue. I am using sample1 script. I can confirm it is working because it is creating and writing the variable. But the server logging is not working. I am trying to use the logging for debugging purposes as the error levels in the log are quite minimal. I don't think the command works? Can you test on your end (I have version 3.0.8) as it is rather important that I can do this in order to write scripts. 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 » Wed Dec 24, 2008 12:25 pm

It is working fine for me here in MLScript. Can I see how you are trying to use it?

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

Postby simonmason » Thu Dec 25, 2008 6:21 pm

This has got me quite perplexed. I am calling the script from a button on one of my scenes. The script is executing because I am writing out to a variable and including the system time and this is updating just fine. Nothing is showing in the log. When I click on test I get a script error 13, type mismatch on the MLServer.LogMLEvent command so I have to believe that the syntax is somehow incorrect in the sample script? My script is below:

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 MySample

dim MyServer
dim MyIPAddr
dim oShell
dim Username
dim tmpStr
dim sEvent
dim sName
dim sTime

Set oShell = CreateObject("WScript.Shell")
Username = oShell.ExpandEnvironmentStrings("%username%")
Set oShell = Nothing

MyServer = MLServer.GetVariable ("server_servername")
MyIPAddr = MLServer.GetVariable ("server_ipaddress")

sEvent = "This is a test"
sName = "server1"
sTime = time

tmpStr = "Hello " & Username & " your server name is " & MyServer & " and its IP Address is " & MyIPAddr & " the time is " & sTime

MLServer.SetVariable "AAATest", tmpStr


MLServer.LogMLEvent MyServer, sEvent, 0


End Sub

Call MySample
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 » Thu Dec 25, 2008 7:33 pm

Ok, now I see what is going on. First the solution. Change the LogEvent line to read

MLServer.LogMLEvent cStr(MyServer), cStr(sEvent), 0

and it will work. The reason it was breaking was that the two variables MyServer and sEvent are declared in the script. VBScript creates these variables of type Variant. However, LogMLEvent expects two variables of type String sent to it. So converting the variables to strings makes everything happy.

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

Postby simonmason » Thu Dec 25, 2008 9:32 pm

Thanks. That worked. Next question. I am trying to load scenes conditionally based on the settings of certain variables. What is the best method for loading a scene - is it with the MLServer.cmdReceive command? 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 » Thu Dec 25, 2008 9:56 pm

Yes use cmdReceive since it will be executed immediately and not put on the queue.

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

Postby simonmason » Fri Dec 26, 2008 6:36 am

ok, what is the syntax for a scene load or overlay load in a vbscript command? I looked all over the wiki but I don't see specific documentation on these ML server commands. I am sure it is there so if you can point me in the right direction that would be great. Thanks.
Simon D. S. Mason

User avatar
ronsatter
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1304
Joined: Mon Dec 04, 2006 1:40 am
Location: San Leandro, CA
Contact:

MLScript Examples

Postby ronsatter » Fri Dec 26, 2008 11:29 am

Simon,

Forgive me for jumping in here. I too am interested in using VBScripts to execute ML commands. This thread is helping me understand what is needed. Thanks to you and Dave for helping us learn through TRIAL & ERROR.

My wish is that Cinemar will provide it's customers with more examples in the wiki to get us moving in the VB Script area. Up to now, if I need a script to execute in ML, I use HomeSeer.

If Cinemar wants to promote less dependency on third party software like HomeSeer (I love HomeSeer and use it for areas where ML falls short), I feel that more effort to provide users with simple "How To" examples would be very productive.

By the way, I never feel like these requests fall on deaf ears. Mario, Dave and the staff at Cinemar are doing a great job!

Here's to a great new year for all of us.

Ron
If it ain't broke ... don't fix it!

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

Postby CinemarDave » Fri Dec 26, 2008 12:35 pm

Here's a sample script to do a change scene on a client

Code: Select all

Option Explicit
Sub Jump (Params)
   Dim Client
   Dim Scene
   If Ubound(Params) = 2 then
      Client = Params(0)
      Scene = Params(1)
      MLServer.cmdReceive "MLCmd|ChangeScene~" & Client & "~" & Scene
    Else
      MLServer.LogMLEvent "Script - ChangeScene", "Incorrect number of parameters passed to function Jump", 0
   End If
End Sub ' Jump


This script expects two parameters. The first is the client name to send the command to and the second is the name of the scene to load.

You call the script using the following syntax.

MLScript|ChangeScene~Jump~{{clientname}}~home.mls

The best place to ask for examples is right here on the forum. There is really little need to use 3rd party apps to run scripts. It's just a matter of learning the syntax. The script examples will be collected over time and placed on the Wiki as a central repository of samples.

User avatar
ronsatter
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1304
Joined: Mon Dec 04, 2006 1:40 am
Location: San Leandro, CA
Contact:

Postby ronsatter » Fri Dec 26, 2008 12:54 pm

Thanks Dave :D

I'm starting a script examples file with this snippet.

Ron
If it ain't broke ... don't fix it!

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

Postby simonmason » Sat Dec 27, 2008 6:42 pm

Brilliant - this worked like a charm. I am busy writing scripts to handle some of my complex scene changes. I am having trouble with a macro. I am sending the following commands in order:

MLServer.cmdReceive "MLCmd|ChangeScene~" & Client & "~" & "0019_media.mls"
MLServer.cmdReceive "Zone.CHA6"

The first changes the scene (to load the media center now playing scene), and the second is supposed to set the zone. I get no errors but the musiclobby scene defaults to the first channel. If I put the second command on a button and push it, it works fine. Any thoughts?
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 » Sat Dec 27, 2008 7:12 pm

When run via MLScript do you see the Zone.CHA6 command being executed in the MLServer event log?


Return to “MLScript”

Who is online

Users browsing this forum: No registered users and 1 guest