Lukas Capek

repeat VBS script

Discussion created by Lukas Capek on Jun 8, 2011
Latest reply on Nov 15, 2011 by Arturo Inzunza Leon

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>

Outcomes