General area when it fits no where else

Moderator: Mmiscool

User avatar
By PhilTilson
#66472 I am posting this in both General and Bugs as I'm not sure it IS a bug and want to have the widest audience!

A while ago I posted in Projects some software for a 'wake-up light' that uses RGB LEDs. This seemed to have been working fine, but recently had crashed every time it started up, sometimes doing multiple crashes which were difficult to interrupt!

Having done some debugging, the problem seems to be with CSSID. I establish some buttons for controlling the light with lines like this:

Code: Select allbutton "Morning", [dayon]
btnday = htmlid()
cssid btnday, "background-color: lightgray; left: 130px;"

Later in the program, if the button is clicked, I call the routine:

Code: Select all[dayon]
io(pwo,rr,daylevel)
io(pwo,gg,daylevel)
io(pwo,bb,daylevel)
cssid btnday, "background-color: aqua;"
serialprintln dtg$ & "  Day_on: " & daylevel
wait

in order to change the button colour to indicate that the day lights are on. This works. Later, to turn them off, I use:

Code: Select all[alloff]
day_inc_active = 0
inclevel = 0
night_active = 0
io(pwo,rr,0)
io(pwo,gg,0)
io(pwo,bb,0)
cssid btnday, "background-color: lightgray;"
cssid btnnight, "background-color: lightgray;"
serialprintln dtg$ & "  All Off"
wait

This seems to work the first time, but subsequent calls cause a crash and memory dump. Once rebooted, I try again and the same thing happens.

If I remove the CSSID calls, the system is rock solid.

Surely I should be able to save the values obtained from HTMLID() in a variable and then use it subsequently for CSSID? It seems to work fine most of the time, but not here!

If anyone wants the full code to try running it to see if you get the same problem, let me know and I'll post it.

Phil
User avatar
By Oldbod
#66474 I know absolutely nothing about writing web pages. So the only thoughts I have are, are you retrieving the htmlid value at the right time, and does it stay current at the point where btnnight is being used (I'm assuming that though it's not in the code snippet, you set btnnight appropriately).

You might, if not alreadyvdone, try using the same cssid setting for each variable, just to see if it still bonks out. Or other combinations to see if you can Id an element which works..... Wonder how big the buffer is...
User avatar
By PhilTilson
#66651
are you retrieving the htmlid value at the right time


Well, according to the documentation, "This should be executed immediately after creating a GUI object", and since it's the line following "button "Morning", [dayon]", I assume I am! Also, this DOES work initially - it's just that it crashes the system thereafter.

Again, as I assign it to a variable, which never gets reassigned in the code, it should certainly stay current.

Your comment about the buffer is appropriate, as the error message I get when this occurs says something about the buffer being full, but since it's such a trivial web page, compared with many others on this site, I don't know why!

Phil