General area when it fits no where else

Moderator: Mmiscool

User avatar
By joeman2116
#48231 The code below is from bits and pieces of various project examples - mostly the thermostat project
Was not sure where to post for help

1. The program is working fine.
2. My problem is I cannot figure out the proper syntax / code to put a variable inside an html table /box
3. Current code displays the htmlvar(curr) and htmlvar(tf) as text but not the actual variables.


Any help would be much appreciated.
Thanks
joe

SEE CODE Below




memclear
SERIALPRINTLN "restart page"
cls

let tf = 0
let curr = 0
let setp = 31
let stat = On

wprint "<head>"
wprint "<meta http-equiv='refresh'content='10;URL=/input?'>"
wprint "</head>"

wprint "<table bgcolor='lightblue' border='1' cellpadding='5'>"
wprint "<th><h1>WiFi Cooling Thermostat !</h1></th>"
wprint "<th</th></table><br>"

wprint "<div><table bgcolor='Yellow' border='1' cellpadding='5'>"
wprint "<tr><th>Sensor</th><th>TempC</th><th>TempF</th></tr>"
wprint "<tr><td>DS18B20P</td>"
wprint "<td bgcolor='cyan'>"
wprint "htmlvar(curr)</td>"
wprint "<td bgcolor='lightgreen'>wprint htmlvar(tf)</td></tr>"

'wprint "<tr><td>DS18B20P</td><td bgcolor='cyan'>wprint htmlvar(curr)</td><td bgcolor='lightgreen'>wprint htmlvar(tf)</td></tr>"

print
Button "Set Temperature" [setpt]
textbox setp
wprint "<br><br>"
wprint "Current Temp - Celsius= "
wprint "<br><br>"
wprint "Current Temp - Fahrenheit= "
wprint htmlvar(tf)
wprint "<br><br><br><br>"

wprint "COOLING FAN="
wprint htmlvar(stat)
wprint "<br><br><br>"
Button "Exit" [quit]
wprint "<br>"
timer 4000, [refresh]
wprint "<br>"
wait

[on2]
po D2 1
SERIALPRINTLN "GPIO 2 ON"
let stat = "On"
Wait

[off2]
po D2 0
SERIALPRINTLN "GPIO 2 OFF"
let stat = "Off"
Wait

[setpt]
wprint "<head>"
wprint "<meta http-equiv='refresh' content='10;URL=/input?'>"
wprint "</head>"

Wait

[refresh]

temp 0 curr ' read current temperature for device 0 db1820
tf = curr * 9
tf = tf / 5
tf = tf + 32
SERIALPRINTLN curr
SERIALPRINTLN tf
if curr > setp then goto [on2] else goto [off2] 'TURN FAN ON IF CURRENT TEMP IS GREATER THEN SETP
Wait

[quit]
timer 0
wprint "<a href='/'>Menu</a>"
end
User avatar
By Mmiscool
#48293 The htmlvar() function can not be used in the way you have it set up.

Code: Select allwprint "htmlvar(curr)</td>"


It needs to be set up like the below.
Code: Select allwprint htmlvar(curr) & "</td>"


You had the function inside the quotation marks and it was not being evaluated by the interpreter.
User avatar
By joeman2116
#48303
Mmiscool wrote:The htmlvar() function can not be used in the way you have it set up.

Code: Select allwprint "htmlvar(curr)</td>"


It needs to be set up like the below.
Code: Select allwprint htmlvar(curr) & "</td>"


You had the function inside the quotation marks and it was not being evaluated by the interpreter.

Thanks.

The temperatures are now displayed ,but at the top of the screen,and
not within the cyan and light green table boxes.

I tried all kinds of combinations but none worked.


SEE CODE BELOW:


wprint "<head>"
wprint "<meta http-equiv='refresh'content='10;URL=/input?'>"
wprint "</head>"

wprint "<table bgcolor='lightblue' border='1' cellpadding='5'>"
wprint "<th><h1>WiFi Cooling Thermostat !</h1></th>"
wprint "<th</th></table><br>"
wprint "<div><table bgcolor='Yellow' border='1' cellpadding='5'>"
wprint "<tr><th>Sensor</th><th>TempC</th><th>TempF</th></tr>"
wprint "<tr><td>DS18B20P</td>"
wprint "<td bgcolor='cyan'></td>"
wprint htmlvar(curr) & "</td>"
wprint "<td bgcolor='lightgreen'></td>"
wprint htmlvar(tf) & "</td></tr>"