Announcement

Collapse
No announcement yet.

Problem with output state.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Problem with output state.

    I am running the following script
    <php>
    Sub Main(ByVal parm As Object)
    Dim strResults As String = ""

    ' Turn output 011 On
    strResults = hs.plugin("UltraM1G").ControlOutput("011", "Off", "0")
    If strResults.Length > 0 Then
    Call hs.WriteLog("Error", strResults)
    End If

    ' Get output state
    Dim Output As Hashtable = hs.plugin("UltraM1G").GetOutputState("011")
    If Output Is Nothing Then
    ' Unable to get output state
    Else
    ' Do cool stuff with these results
    Dim strOutputName = Output("Name")
    Dim strOutputStatus = Output("Status")
    Dim strOutputLastChange = Output("LastChange")
    hs.WriteLog ("ULTRA TEST", "Name " & strOutputName & "-Status " & strOutputStatus & "-LastChange " & strOutputLastChange)

    End If


    End Sub
    </php>

    But I get the following error in my log.

    7/8/2008 1:55:48 AM Error Script compile error: Type 'Hashtable' is not defined.on line 24

    #2
    I had to change the "New Hashtable()" to "New System.Collections.Hashtable()" as follows:

    PHP Code:
    Dim Output As New System.Collections.Hashtable()
    Output hs.plugin("UltraM1G").GetOutputState("011"
    Updated script:
    PHP Code:
    Sub Main(ByVal parm As Object)

        
    Dim strResults As String ""

        ' Turn output 011 On 
        strResults = hs.plugin("UltraM1G").ControlOutput("011", "Off", "0")
        If strResults.Length > 0 Then
            Call hs.WriteLog("Error", strResults)
        End If

        ' 
    Get output state
        Dim Output 
    As New System.Collections.Hashtable()
        
    Output hs.plugin("UltraM1G").GetOutputState("011")

        If 
    Output Is Nothing Then
            
    ' Unable to get output state
        Else
            ' 
    Do cool stuff with these results
            Dim strOutputName 
    As String Output("Name")
            
    Dim strOutputStatus As String Output("Status")
            
    Dim strOutputLastChange As String Output("LastChange")
            
    hs.WriteLog("ULTRA TEST""Name " strOutputName "-Status " strOutputStatus "-LastChange " strOutputLastChange)
        
    End If

    End Sub 
    Regards,
    Ultrajones
    Plug-ins: UltraMon, UltraM1G, UltraCID, Ultra1Wire, UltraLog, UltraWeatherBug, UltraPioneerAVR, UltraGCIR

    Comment

    Working...
    X