0

Getting User Variables crashes script

I made a script to match the time of day to 3 user variables I get the user variables and convert them to an INT using VAR(), but when I use m.userVariables.Lookup("test").GetCurrentValue() for all 3 variables it works only works once and then the player gets stuck or crashes shortly after that.

So I do this:

-----------------------------------

' Get System time
t = CreateObject("roSystemTime")
gedat = t.GetLocalDateTime()
sDate = gedat.ToIsoString()
sHour = Mid(sDate, 10, 2)
sMin = Mid(sDate, 12, 2)
sTime = sHour+sMin
tTime = VAL(sTime)

' Get uservariables
isplaying = m.userVariables.Lookup("myclip").GetCurrentValue()

userMorn = VAR(m.userVariables.Lookup("uvmorn").GetCurrentValue())
userAftr = VAR(m.userVariables.Lookup("uvafter").GetCurrentValue())
userEven = VAR(m.userVariables.Lookup("uveven").GetCurrentValue())


theText = sTime + "/" + userMorn + "/" + userAftr + "/" + userEven
' Set dynamic textfield variable
m.userVariables.Lookup("mytext").SetCurrentValue(theText,true)

-----------------------------------------

and then use send plugin commands later to play the correct video. For instance:

-------------------------------------

if tTime >= userMorn AND tTime < userAftr AND isplaying <> "morning" then 'Morning
' send Plugin message
pluginMessageCmd = CreateObject("roAssociativeArray")
pluginMessageCmd["EventType"] = "EVENT_PLUGIN_MESSAGE"
pluginMessageCmd["PluginName"] = "Timeday"
pluginMessageCmd["PluginMessage"] = "morning"
m.msgPort.PostMessage(pluginMessageCmd)
endif

-------------------------------------

If I only get the value of 1 variable it works fine, and if use just static INT values in the IF statement instead of the variables in the script it also works fine.

Any clue what might be going wrong here?

3 comments

  • 0
    Avatar
    Bright Scripters info[at]brightscripters.com

    The word "crash" is an indication that you are not using the serial / ssh command line debugger, or console.

    You would benefit from adopting a development workflow which is supported by debugging info, rather than guessing what is wrong.

    https://brightsign.zendesk.com/hc/en-us/articles/218066947-How-do-I-enable-script-debug-mode-on-the-player-

     

    Once you get that working, you can use the BrightScript print command, to output messages to the console. 

     

    Example:

     

    sDate = gedat.ToIsoString()

    print "Local Date Time is: "; sDate 

  • 0
    Avatar
    Brandon

    @Ingmar
    What is the VAR function you're calling in the assignment of the variables after isplaying?

    _________________________________________________________________________

    Friendly reminder, the community forum is intended for user-to-user discussion.  It is not regularly monitored. For troubleshooting problems and to ensure a timely answer from a BrightSign representative, please submit a support ticket.

  • 0
    Avatar
    Lyndon

    If any of those variables are invalid, it would crash. You should verify the returned object is valid before calling getcurrentvalue(). There's not enough information here to give a more definitive answer. 

Please sign in to leave a comment.