-->
Page 1 of 2

v1.15 issue For-Next

PostPosted: Tue Nov 03, 2015 9:05 pm
by xtal
Loaded v1.15 and tested the For - Next loop

[ForNext]
for x = 1 to 5
if x = 1 then serialprintln "pass 1"
if x = 2 then serialprintln "pass 2"
if x = 3 then serialprintln "pass 3"
if x = 4 then serialprintln "pass 4"
if x = 5 then serialprintln "pass 5"
next x
wait

now back to original problem it appears that only 1 step is being executed / 15 sec refresh

Have not tried this out side of the button code .....

Code: Select allmycommand = " "
cnt = "1"
rfctr = 0
adc_id = 0
adc_value = 512
k1 = 0.11
p00 = 'P'
apc0 = 40000
ppm0 = 1770
adj1 = 1768
adj2 = 1769
cdeg0 = 25.1
fdeg0 = 77.18
kta0 = '0.01'
lo0 = '12'
hi0 = '20'
prb = '01.0'
ph = '7.0'
s0 = "000> 00001,00032 00342,65535 00700,66535 01000,34770 01400,65535"
 
 
bgc = 'Yellow'
B_Opn = 'http://i.imgur.com/kzt3tO8.png'
B_Clo = 'http://i.imgur.com/KS1dPa7.png'
Ipage = B_Clo

rfh = '15'

wprint "<meta http-equiv='refresh' content='15' >"

wprint "<script type = 'text/javascript'>"
wprint "var timeInSecs;"
wprint "var ticker;function startTimer(secs){"
wprint "timeInSecs = parseInt(secs)-1;"
wprint "ticker = setInterval('tick()',1000);}"
wprint "function tick() {"
wprint "var secs = timeInSecs;"
wprint "if (secs>0) {timeInSecs--;} else {clearInterval(ticker);"
wprint "startTimer(15);}document.getElementById('countdown').innerHTML = secs;} startTimer(15);"
wprint "</script>"
wprint "<body><div>"
wprint "<table bgcolor='Lawngreen' border='1' cellpadding='5'>"
wprint "<th><h1>ESP8266 Blinker Thing!</h1></th>"

 
wprint "<td><IMG SRC ="
wprint htmlvar(Ipage)
wprint " LEFT='1' WIDTH='120' HEIGHT='60' BORDER='1'></td>"
 

wprint "<th id='countdown'>15</th></table><br>"

wprint "<div><textarea name='cmd1s' cols='85' rows='14'>"
wprint htmlvar(s0)
wprint chr(13)
 
wprint "</textarea></div><br>"

wprint "<div><textarea name='cmd2s' cols='85' rows='6'>"
wprint htmlvar(s0)
wprint chr(10)

wprint "</textarea></div><br>"

wprint "<div><table bgcolor="
wprint htmlvar(bgc)
wprint " border='1' cellpadding='5'>"
wprint "<tr><th>Sensor</th><th>TempC</th><th>TempF</th><th>PPMcntr</th>"
wprint "<th>PPM__</th><th>Adj__1</th><th>Adj__2</th></tr>"
wprint "<tr><td>DS18B20P</td><td>"
wprint htmlvar(cdeg0)
wprint "</td><td>"
wprint htmlvar(fdeg0)
wprint "</td><td>"
wprint htmlvar(apc0)
wprint "</td><td>"
wprint htmlvar(ppm0)
wprint "</td><td>"
wprint htmlvar(adj1)
wprint "</td><td>"
wprint htmlvar(adj2)
wprint "</td></tr>"
wprint "<tr><th>Probe-K</th><th>Pool-PH</th><th>PH-Adj</th><th>ADC Value</th></tr>"
wprint "<tr><td>01.0</td><td>7.0</td><td>7</td><td bgcolor='Red'>"
wprint htmlvar(adc_value)
wprint "</td></tr></table></div><br>"

button "BLINK" [BLINK]
button "RD_ADC" [RDA.DC]
button "TEMP_DN" [TEMP.DN]
button "TEMP_UP" [TEMP.UP]
button "F_Deg" [Fdeg]
button "ForNxt" [ForNext]
WPRINT "<BR>CMD:"
textbox mycommand
button "SUBMIT" [SUBMIT.BRANCH]
wprint "<br>



wait


[BLINK]
if Ipage == B_Clo then Ipage = B_Opn else Ipage = B_Clo
wait


[RDA.DC]
AI adc_value
wait

[TEMP.DN]
SERIALPRINTLN "you clicked temp dn"
cdeg0 = cdeg0 - 0.1
fdeg0 = cdeg0 * 1.8
fdeg0 = fdeg0 + 32
ppm0 = ppm0 - 1
apc0 = apc0 - 1
adj1 = adj1 - 1
adj2 = adj2 - 1

wait

[TEMP.UP]
SERIALPRINTLN "you clicked temp up"
cdeg0 = cdeg0 + 0.1
fdeg0 = cdeg0 * 1.8
fdeg0 = fdeg0 + 32
ppm0 = ppm0 + 1
apc0 = apc0 + 1
adj1 = adj1 + 1
adj2 = adj2 + 1

wait
 
[Fdeg]
fdeg0 = cdeg0 * 1.8
fdeg0 = fdeg0 + 32
serialprintln fdeg0

wait

[ForNext]
for x = 1 to 5
    if x = 1 then serialprintln "pass 1"
    if x = 2 then serialprintln "pass 2"
    if x = 3 then serialprintln "pass 3"
    if x = 4 then serialprintln "pass 4"
    if x = 5 then serialprintln "pass 5"
next x
wait
 
[SUBMIT.BRANCH]
SERIALPRINTLN mycommand
if bgc == 'Yellow' then bgc = 'Cyan' else bgc = 'Yellow'
 
wait

Re: v1.15 issue For-Next

PostPosted: Wed Nov 04, 2015 3:53 am
by Mmiscool
Posted new build that is much quicker on for next loops. A similar fix was done to goto statements that makes them quicker.

Re: v1.15 issue For-Next

PostPosted: Wed Nov 04, 2015 9:09 am
by xtal
Its interesting that the previous build [1.13 I think] that the first pass went fast and then slow passes
will try the new code :mrgreen:
[SUBMIT] textbox = eerfh20
x = instr(mycommand,'rfh') --------> tried "rfh" same
y = mid(mycommand,x + 3,2)
SERIALPRINTLN mycommand
SERIALPRINTLN x
serialprintln y

the above code --->
eerfh20 <----- textbox
0 <--------------- x
3.00 <----------- y






V1.17

Well it's improved but has farther to go, based on the speed I previously saw on that 1st pass...
it went zip, this goes click,click,ckick it's much to slow even for an interpeted language....

The code isn't finished yet , need to add serial input , unfortunately buffer size will be too great
for the displays I want in the textarea. Maybe you will tokenize later :mrgreen:

Speaking of serial input How will the page refresh after the serial input.

Attached is latest script... The java script 15 sec tmr and refresh is now controlled by var rfh I havn't change the val yet.... :roll:
Code: Select allmycommand = " "
cnt = "1"
rfctr = 0
adc_id = 0
adc_value = 512
k1 = 0.11
p00 = 'P'
apc0 = 40000
ppm0 = 1770
adj1 = 1768
adj2 = 1769
cdeg0 = 25.1
fdeg0 = 77.18
kta0 = '0.01'
lo0 = '12'
hi0 = '20'
prb = '01.0'
ph = '7.0'
s0 = "000> 00001,00032 00342,65535 00700,66535 01000,34770 01400,65535"
 
 
bgc = 'Yellow'
B_Opn = 'http://i.imgur.com/kzt3tO8.png'
B_Clo = 'http://i.imgur.com/KS1dPa7.png'
Ipage = B_Clo

rfh = 15

wprint "<meta http-equiv='refresh' content="
wprint htmlvar(rfh)
wprint "rfh >"

wprint "<script type = 'text/javascript'>"
wprint "var timeInSecs;"
wprint "var ticker;function startTimer(secs){"
wprint "timeInSecs = parseInt(secs)-1;"
wprint "ticker = setInterval('tick()',1000);}"
wprint "function tick() {"
wprint "var secs = timeInSecs;"
wprint "if (secs>0) {timeInSecs--;} else {clearInterval(ticker);"
wprint "startTimer("
wprint htmlvar(rfh)
wprint ");}document.getElementById('countdown').innerHTML = secs;} startTimer("
wprint html(rfh)
wprint ");"
wprint "</script>"
wprint "<body><div>"
wprint "<table bgcolor='Lawngreen' border='1' cellpadding='5'>"
wprint "<th><h1>ESP8266 Blinker Thing!</h1></th>"

 
wprint "<td><IMG SRC ="
wprint htmlvar(Ipage)
wprint " LEFT='1' WIDTH='120' HEIGHT='60' BORDER='1'></td>"
 

wprint "<th id='countdown'>"
wprint htmlvar(rfh)
wprint "</th></table><br>"

wprint "<div><textarea name='cmd1s' cols='70' rows='14'>"
wprint htmlvar(s0)
wprint chr(13)
 
wprint "</textarea></div><br>"

wprint "<div><textarea name='cmd2s' cols='70' rows='6'>"
wprint htmlvar(s0)
wprint chr(10)

wprint "</textarea></div><br>"

wprint "<div><table bgcolor="
wprint htmlvar(bgc)
wprint " border='1' cellpadding='5'>"
wprint "<tr><th>Sensor</th><th>TempC</th><th>TempF</th><th>PPMcntr</th>"
wprint "<th>PPM__</th><th>Adj__1</th><th>Adj__2</th></tr>"
wprint "<tr><td>DS18B20P</td><td>"
wprint htmlvar(cdeg0)
wprint "</td><td>"
wprint htmlvar(fdeg0)
wprint "</td><td>"
wprint htmlvar(apc0)
wprint "</td><td>"
wprint htmlvar(ppm0)
wprint "</td><td>"
wprint htmlvar(adj1)
wprint "</td><td>"
wprint htmlvar(adj2)
wprint "</td></tr>"
wprint "<tr><th>Probe-K</th><th>Pool-PH</th><th>PH-Adj</th><th>ADC Value</th></tr>"
wprint "<tr><td>01.0</td><td>7.0</td><td>7</td><td bgcolor='Red'>"
wprint htmlvar(adc_value)
wprint "</td></tr></table></div><br>"

button "BLINK" [BLINK]
button "RD_ADC" [RDA.DC]
button "TEMP_DN" [TEMP.DN]
button "TEMP_UP" [TEMP.UP]
button "F_Deg" [Fdeg]
button "ForNxt" [ForNext]
WPRINT "<BR>CMD:"
textbox mycommand
button "SUBMIT" [SUBMIT.BRANCH]
wprint "<br>



wait


[BLINK]
if Ipage == B_Clo then Ipage = B_Opn else Ipage = B_Clo
wait


[RDA.DC]
AI adc_value
wait

[TEMP.DN]
SERIALPRINTLN "you clicked temp dn"
cdeg0 = cdeg0 - 0.1
fdeg0 = cdeg0 * 1.8
fdeg0 = fdeg0 + 32
ppm0 = ppm0 - 1
apc0 = apc0 - 1
adj1 = adj1 - 1
adj2 = adj2 - 1

wait

[TEMP.UP]
SERIALPRINTLN "you clicked temp up"
cdeg0 = cdeg0 + 0.1
fdeg0 = cdeg0 * 1.8
fdeg0 = fdeg0 + 32
ppm0 = ppm0 + 1
apc0 = apc0 + 1
adj1 = adj1 + 1
adj2 = adj2 + 1

wait
 
[Fdeg]
fdeg0 = cdeg0 * 1.8
fdeg0 = fdeg0 + 32
serialprintln fdeg0

wait

[ForNext]
for x = 1 to 5
    if x = 1 then serialprintln "pass 1"
    if x = 2 then serialprintln "pass 2"
    if x = 3 then serialprintln "pass 3"
    if x = 4 then serialprintln "pass 4"
    if x = 5 then serialprintln "pass 5"
next x

wait

 
[SUBMIT.BRANCH]
SERIALPRINTLN mycommand
if bgc == 'Yellow' then bgc = 'Cyan' else bgc = 'Yellow'
 
wait

Re: v1.15 issue For-Next

PostPosted: Wed Nov 04, 2015 6:08 pm
by Mmiscool
THis seems to work for me

Right now inline math evaluations are not there. So you have to do the math outside of the function.

Code: Select allmycommand = "eerfh20"
x = instr(mycommand,rfh)
z = x + 3
y = mid(mycommand,x,z)
SERIALPRINTLN mycommand
SERIALPRINTLN x
serialprintln y
end