Program with many comments show where bugs were found
Posted: Sun Jun 26, 2016 8:02 am
Below is a program with many comments showing where I experienced bugs.
I can't get the slider to monitor and control the angle of the line of text. When I move the slider, the text angle should change, and there should be a way to see angle's numerical value.
The program works as given below, with the lines that are commented out. But those lines should also work.
'PROGRAM TO PRESS BUTTONS AND USE THE SLIDER:
'memclear -- when this is here, q=50 below creates an error, Comparison between string and number. It is not clear when (if) memclear is needed.
led = D3
io(po,led,1) 'start with led D3 OFF
'q=50 'does not work, comparison between string and number
'v=str (q) 'here (with q assigned) this it said "halted at line <this line> syntax error
'v$=str (q) 'here (with q assigned) it said "could not look up value for variable. error.
'timer 1000 , [checkslider] - with this statement active, the program would eventually crash (in less than 30 minutes) - when this statement is commented out, the program was solid.
'html |<a href="www.google.com">test</a>| 'this does not put a link here - using wprint does not do it either.
'This block below works:
wprint "Free flash="
wprint flashfree()
html "<br/>"
wprint "Free ram="
wprint ramfree()
html "<br/>"
wprint "Chip id="
wprint id()
html "<br/>"
wprint version()
html "<br/>"
wprint "IP="
wprint ip()
wprint "<p/><p>"
IMAGEBUTTON "ON.PNG", [ON]
IMAGEBUTTON "OFF.PNG", [OFF]
'html |<a href="www.google.com">test</a>| 'this does not put a link here - wprint does not do it either
html "<p/><p>"
'these buttons below work here
button "Turn On",[ON]
button "Turn Off",[OFF]
html "<br/>"
graphics 300,300
html "<br/>"
wprint " " 'put some spaces in front of the slider
'slider "angle",0,100 'it found nothing wrong with this, but it is not standard to put a varname into a string
slider angle,0,100
html "<br/>"
'v=33.5 'declare and set v equal to 22 ' - this does not work here - "comparison between string and float"
'wprint v$ 'this printed as "v$" when the lines near the top which assigned to v and v$ were commented out - could add "variable does not exist"
'wprint v 'this printed as "v" when the lines near the top which assigned to v and v$ were commented out - could add "variable does not exist"
'z=33.5 'this does not work - Comparison between string and number
'b$= str(z) 'this does not work - Comparison between string and number
'b$ = str(33.5) 'this works because in the textbox below we find "33.5", but we really want a numeric variable
'b$="Value" 'this does work because in the textbox we find the word, "Value"
'textbox b$ 'this works when b$ = "Value"
'here we want to print the value of the slider
'b=50 'this does not work - Comparison between string and number
'wprint chr(50) 'this works because we see a "2" displayed
'q=50 'this couplet does not work - even if q is assigned at the top
'wprint chr(q)
'wprint q 'this prints a zero even when q is assigned to 50 above q=50
wprint "The slider value under the slider="
[TOP]
gcls
if io(laststat,led) = 1 then
text 20, 60, "The Green Led is OFF", 30, 12
else
text 20, 60, "The Green Led is ON", -30, 2
end if
'this is where the program can monitor the slider value - angle does not print
'timer 1000 , [checkslider]
[checkslider]
' print angle - this of course results in printing line after line at the bottom text
text 50, 60, "Text Angle=",0,0
' text 140,60,str (angle),0,0 - the str(angle) results in an error, cannot put this text here
wait
[ON]
io(po,led,0)
goto [TOP]
[OFF]
io(po,led,1)
goto [TOP]
I can't get the slider to monitor and control the angle of the line of text. When I move the slider, the text angle should change, and there should be a way to see angle's numerical value.
The program works as given below, with the lines that are commented out. But those lines should also work.
'PROGRAM TO PRESS BUTTONS AND USE THE SLIDER:
'memclear -- when this is here, q=50 below creates an error, Comparison between string and number. It is not clear when (if) memclear is needed.
led = D3
io(po,led,1) 'start with led D3 OFF
'q=50 'does not work, comparison between string and number
'v=str (q) 'here (with q assigned) this it said "halted at line <this line> syntax error
'v$=str (q) 'here (with q assigned) it said "could not look up value for variable. error.
'timer 1000 , [checkslider] - with this statement active, the program would eventually crash (in less than 30 minutes) - when this statement is commented out, the program was solid.
'html |<a href="www.google.com">test</a>| 'this does not put a link here - using wprint does not do it either.
'This block below works:
wprint "Free flash="
wprint flashfree()
html "<br/>"
wprint "Free ram="
wprint ramfree()
html "<br/>"
wprint "Chip id="
wprint id()
html "<br/>"
wprint version()
html "<br/>"
wprint "IP="
wprint ip()
wprint "<p/><p>"
IMAGEBUTTON "ON.PNG", [ON]
IMAGEBUTTON "OFF.PNG", [OFF]
'html |<a href="www.google.com">test</a>| 'this does not put a link here - wprint does not do it either
html "<p/><p>"
'these buttons below work here
button "Turn On",[ON]
button "Turn Off",[OFF]
html "<br/>"
graphics 300,300
html "<br/>"
wprint " " 'put some spaces in front of the slider
'slider "angle",0,100 'it found nothing wrong with this, but it is not standard to put a varname into a string
slider angle,0,100
html "<br/>"
'v=33.5 'declare and set v equal to 22 ' - this does not work here - "comparison between string and float"
'wprint v$ 'this printed as "v$" when the lines near the top which assigned to v and v$ were commented out - could add "variable does not exist"
'wprint v 'this printed as "v" when the lines near the top which assigned to v and v$ were commented out - could add "variable does not exist"
'z=33.5 'this does not work - Comparison between string and number
'b$= str(z) 'this does not work - Comparison between string and number
'b$ = str(33.5) 'this works because in the textbox below we find "33.5", but we really want a numeric variable
'b$="Value" 'this does work because in the textbox we find the word, "Value"
'textbox b$ 'this works when b$ = "Value"
'here we want to print the value of the slider
'b=50 'this does not work - Comparison between string and number
'wprint chr(50) 'this works because we see a "2" displayed
'q=50 'this couplet does not work - even if q is assigned at the top
'wprint chr(q)
'wprint q 'this prints a zero even when q is assigned to 50 above q=50
wprint "The slider value under the slider="
[TOP]
gcls
if io(laststat,led) = 1 then
text 20, 60, "The Green Led is OFF", 30, 12
else
text 20, 60, "The Green Led is ON", -30, 2
end if
'this is where the program can monitor the slider value - angle does not print
'timer 1000 , [checkslider]
[checkslider]
' print angle - this of course results in printing line after line at the bottom text
text 50, 60, "Text Angle=",0,0
' text 140,60,str (angle),0,0 - the str(angle) results in an error, cannot put this text here
wait
[ON]
io(po,led,0)
goto [TOP]
[OFF]
io(po,led,1)
goto [TOP]