repeat VBS script

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

repeat VBS script

774 Views
kurna
Contributor I

Hi, I use Freemaster for reading data from my 8-MCU. I am trying to make simple HTML page, which is usualy reading variables from MCU. I have problem with repeat reading instructions. I need every 5 seconds read variables from MCU and show it in HTML page, but with my code it read only once and then nothing. I tryed to use timeout, but it doesnt work.

Thank you for advice.

 

<body BGCOLOR=white>
<object name="pcm" width="0" height="0"
classid="clsid:48A185F1-FFDB-11D3-80E3-00C04F176153"></object>

<script type="text/vbscript">
Dim Teplota(5)
Dim Vlhkost(5)
Dim Sensor(5)
Dim Signal(5)
Dim flag

Function Update()
flag = pcm.ReadVariable("Sensors_data[1].temperature", Teplota(1), tValue, bsRetMsg)
flag = pcm.ReadVariable("Sensors_data[1].humidity", Vlhkost(1), tValue, bsRetMsg)
flag = pcm.ReadVariable("Sensors_data[2].temperature", Teplota(2), tValue, bsRetMsg)
flag = pcm.ReadVariable("Sensors_data[2].humidity", Vlhkost(2), tValue, bsRetMsg)
flag = pcm.ReadVariable("Sensors_data[3].temperature", Teplota(3), tValue, bsRetMsg)
flag = pcm.ReadVariable("Sensors_data[3].humidity", Vlhkost(3), tValue, bsRetMsg)
flag = pcm.ReadVariable("Sensors_data[4].temperature", Teplota(4), tValue, bsRetMsg)
flag = pcm.ReadVariable("Sensors_data[4].humidity", Vlhkost(4), tValue, bsRetMsg)
flag = pcm.ReadVariable("Sensors_data[5].temperature", Teplota(5), tValue, bsRetMsg)
flag = pcm.ReadVariable("Sensors_data[5].humidity", Vlhkost(5), tValue, bsRetMsg)

 

For i=1 To 5

    Vlhkost(i)=Vlhkost(i)/10
    Teplota(i)=Teplota(i)/10
    document.write("<TR>")
    document.write("<TD WIDTH=200>")
    document.write("<H2>Jednotka ")
    document.write(i)
    document.write("</H2></TD>")
    document.write("<TD WIDTH=200 ALIGN=RIGHT><H2 TEXT=red><FONT COLOR=red>")
    document.write(Teplota(i))
    document.write("°C")
    document.write("</FONT></H1></TD>")
    document.write("<TD ALIGN=RIGHT WIDTH=200><H2><FONT COLOR=blue>")
    document.write(Vlhkost(i))
    document.write(" %")
    document.write("</FONT></H2></TD>")
    document.write("<TD ALIGN=RIGHT WIDTH=300><H2>")

Next


end function

SetTimeout "Update()", 5000
</script>

</body>



</html>

Labels (1)
0 Kudos
Reply
1 Reply

438 Views
Inzunzo
Contributor I

I use this and works OK. Hope it helps.

 

<script type="text/vbscript">
            
Sub ReadSettings
    Dim succ,v,tv,retMsg

    succ = pcm.ReadVariable("u8_Batt",v,tv,retMsg)
    
    If succ then

        anyVariableYouWant = tv
        anyErrorDisplayYouWant = "No Errors!"
    else
        anyErrorDisplayYouWant = retMsg
    End If

    setTimeout "ReadSettings",5000
End Sub    

</script>

    </head>
        <body>

        <object classid="clsid:48A185F1-FFDB-11D3-80E3-00C04F176153"
                id=MCB_PC_Master_Services1
                name="pcm" width="0" height="0">
        </object>
                
        </body>            
    </html>
    
           
Good Luck

0 Kudos
Reply