Issue with script with clientname parameter

Forum to discuss MLScript plugin that enables VBScript and JavaScript scripting within MLServer3.
Blade
Expert
Expert
Posts: 760
Joined: Tue Nov 09, 2004 9:38 pm
Location: Lucan, Ontario
Contact:

Issue with script with clientname parameter

Postby Blade » Fri Aug 07, 2009 12:43 pm

I am trying to use the following script but it is not working.
I think it is dying trying to use a variable name as the parameter to the MLServer.GetVariable call.

Code: Select all

Sub FixArtistBioDates (Params)

    dim client
    dim variableName
    dim theBornDate
    dim theDiedDate
    dim theNewBornDate
    dim theNewDiedDate
    dim splitArray
    dim monthName

    client = Params(0)

    ' fix born date
    variableName = "music_artistbio_born_" & client
    theBornDate = MLServer.GetVariable(variableName)

    if Len(Trim(theBornDate) ) > 0 then
        splitArray = Split(Trim(theBornDate), " ")
        if splitArray(1) = "1" then
            monthName = "Jan"
        elseif splitArray(1) = "2" then
            monthName = "Feb"
        elseif splitArray(1) = "3" then
            monthName = "Mar"
        elseif splitArray(1) = "4" then
            monthName = "Apr"
        elseif splitArray(1) = "5" then
            monthName = "May"
        elseif splitArray(1) = "6" then
            monthName = "Jun"
        elseif splitArray(1) = "7" then
            monthName = "Jul"
        elseif splitArray(1) = "8" then
            monthName = "Aug"
        elseif splitArray(1) = "9" then
            monthName = "Sep"
        elseif splitArray(1) = "10" then
            monthName = "Oct"
        elseif splitArray(1) = "11" then
            monthName = "Nov"
        elseif splitArray(1) = "12" then
            monthName = "Dec"
        end if
        theNewBornDate = monthName & " " & splitArray(2) & ", " & splitArray(0)
        MLServer.SetVariable variableName, theNewBornDate
    end if

End Sub

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:

Re: Issue with script with clientname parameter

Postby ronsatter » Fri Aug 07, 2009 10:19 pm

Hi Blade,

I'm glad to see you tackling this. It has been on my wish list.

Just curious ... what happens when you use the actual data in place of the variable? Does the script work? Perhaps it doesn't like the substitution for the client name ... just throwing out questions. As you know, my scripting skills are pathetic ! #-o

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:

Re: Issue with script with clientname parameter

Postby CinemarDave » Sat Aug 08, 2009 1:39 am

Your script is fine you just have a slight oversight. When calling GetVariable and SetVariable you have to make sure you convert the VBScript variables that are always of type "variant" to "strings" using the CStr() command. Your script should look like the following

Code: Select all

Option Explicit
Sub FixArtistBioDates (Params)
    dim client
    dim variableName
    dim theBornDate
    dim theDiedDate
    dim theNewBornDate
    dim theNewDiedDate
    dim splitArray
    dim monthName

    client = Params(0)
    ' fix born date
    variableName = "music_artistbio_born_" & client
    theBornDate = MLServer.GetVariable(cstr(variableName))

    if Len(Trim(theBornDate) ) > 0 then
        splitArray = Split(Trim(theBornDate), " ")
        if splitArray(1) = "1" then
            monthName = "Jan"
        elseif splitArray(1) = "2" then
            monthName = "Feb"
        elseif splitArray(1) = "3" then
            monthName = "Mar"
        elseif splitArray(1) = "4" then
            monthName = "Apr"
        elseif splitArray(1) = "5" then
            monthName = "May"
        elseif splitArray(1) = "6" then
            monthName = "Jun"
        elseif splitArray(1) = "7" then
            monthName = "Jul"
        elseif splitArray(1) = "8" then
            monthName = "Aug"
        elseif splitArray(1) = "9" then
            monthName = "Sep"
        elseif splitArray(1) = "10" then
            monthName = "Oct"
        elseif splitArray(1) = "11" then
            monthName = "Nov"
        elseif splitArray(1) = "12" then
            monthName = "Dec"
        end if
        theNewBornDate = monthName & " " & splitArray(2) & ", " & splitArray(0)
        MLServer.SetVariable cstr(variableName), cstr(theNewBornDate)
    end if
End Sub


However, I'll make sure the next version of MusicLobby creates these date variables in a more friendly format.

Blade
Expert
Expert
Posts: 760
Joined: Tue Nov 09, 2004 9:38 pm
Location: Lucan, Ontario
Contact:

Re: Issue with script with clientname parameter

Postby Blade » Sat Aug 08, 2009 1:11 pm

Thx Dave. I knew it was something simple.

Here is the command to call the script:

MLScript|Music_FixArtistBioDates~FixArtistBioDates~{{clientname}}

Here is the full script:

Code: Select all

Sub FixArtistBioDates (Params)

    dim client
    dim variableName
    dim theBornDate
    dim theDiedDate
    dim theNewBornDate
    dim theNewDiedDate
    dim splitArray

    client = Params(0)

    ' fix born date
    variableName = "music_artistbio_born_" & client
    theBornDate = MLServer.GetVariable(cstr(variableName))

    if Len(Trim(theBornDate) ) > 0 then
        splitArray = Split(Trim(theBornDate), " ")
        theNewBornDate = GetMonthName(splitArray(1)) & " " & splitArray(2) & ", " & splitArray(0)
        MLServer.SetVariable (cstr(variableName)), theNewBornDate
    end if

    ' fix died date
    variableName = "music_artistbio_died_" & client
    theDiedDate = MLServer.GetVariable(cstr(variableName))

    if Len(Trim(theDiedDate) ) > 0 then
        splitArray = Split(Trim(theDiedDate), " ")
        theNewDiedDate = GetMonthName(splitArray(1)) & " " & splitArray(2) & ", " & splitArray(0)
        MLServer.SetVariable (cstr(variableName)), theNewDiedDate
    end if

End Sub

Function GetMonthName(monthNum)

        dim monthName

        if monthNum = "01" then
            monthName = "Jan"
        elseif monthNum = "02" then
            monthName = "Feb"
        elseif monthNum = "03" then
            monthName = "Mar"
        elseif monthNum = "04" then
            monthName = "Apr"
        elseif monthNum = "05" then
            monthName = "May"
        elseif monthNum = "06" then
            monthName = "Jun"
        elseif monthNum = "07" then
            monthName = "Jul"
        elseif monthNum = "08" then
            monthName = "Aug"
        elseif monthNum = "09" then
            monthName = "Sep"
        elseif monthNum = "10" then
            monthName = "Oct"
        elseif monthNum = "11" then
            monthName = "Nov"
        elseif monthNum = "12" then
            monthName = "Dec"
        end if

        GetMonthName = cstr(monthName)

End Function

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:

Re: Issue with script with clientname parameter

Postby ronsatter » Sat Aug 08, 2009 11:12 pm

Thx Blade!

Works like a charm. Now if there were only a way to distinguish between the artist meta data for a single performer and a group. Any ideas, anyone?

PS. Here's some screenshots from my new MUL scenes. (These are custom designed, using elements from 0026 graphics and my own elements)

The right vertical panel area is running a vacation slideshow from PhotoLobby while a real-time sequence of MusicLobby scenes was displayed.

I know ... my taste in music is sooo 50's :roll:

Ron
You do not have the required permissions to view the files attached to this post.
If it ain't broke ... don't fix it!

User avatar
DaveB
Simply Incredible
Simply Incredible
Posts: 3143
Joined: Sun May 30, 2004 10:57 pm
Location: Mays Landing, NJ
Contact:

Re: Issue with script with clientname parameter

Postby DaveB » Sun Aug 09, 2009 9:17 am

Forget all that scripting stuff!! The best feature on Rons screen is the "User Tip" area!! 8)
Thanks!

Dave Bruner
:shock:


Return to “MLScript”

Who is online

Users browsing this forum: No registered users and 1 guest