![]() |
Forum Index : Microcontroller and PC projects : Odd behaviour MMBASIC 5.04.07...
Author | Message | ||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
Code that was working just fine in earlier versions, now does very odd things with the "ON" command. Take this section of code: Routine used to get a password, was working fine, now touching the EXIT button causes it to go directly to the database entries, when it should go back to the main menu. If I put a PRINT Y after the loop, but before the ON command like this: The code then DOES go back to the main menu, but it DOES NOT actually print out the value of Y. If I change the code again to add a 2nd PRINT line like this: Then that also works to go back to the main menu, and prints the value of Y on the console ONCE - even though it should be twice..... Remove both "PRINT Y" commands, and change to END so the program should stop at that point, and it DOES NOT: If I ask the console for "PRINT Y" at this point, it is one - just as it should be. If I change the PRINT Y's to "One" and "Two" like this: I get the following output on the console: ![]() ....note how the code is NOT printing the "One..." line, but it IS printing the "Two..." line. This also takes me back to the main menu. If I CTRL-C at that point, and ask the console for PRINT Y, it gives it back as 2015, which it most certainly should not be. Y can only ever be zero, one, two or three to satisfy the ON commands. If I reflash MMBASIC 5.04.05 and load exactly the same code - no problems, everything works as it should. Bizarre. Y is apparently getting changed by something, but it does not get changed by earlier firmware, but the latest firmware DOES change Y somehow, some way. BUT, if you put in some print statements, Y stays as it should, and the ON command works fine. Really scratching my head at this point.... I know WHY the ON command is passing right through to the database entries routine when you touch EXIT, because with Y being 2015 or so, it is taking the last of the routine labels it can find in the ON command, and hopping to there, but that should never happen, as when you touch the EXIT button, Y is set to 1, then the routine hops out of the loop, and runs the ON command. As Y is set to one, it runs the START routine, which takes it back to the main menu. As I say, all that was working just fine. I will see if I can trim the program and produce a more condensed demo code. Smoke makes things work. When the smoke gets out, it stops! |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
UPDATE: Here is some demo code: ![]() RESULTS: ![]() The result is that "Two..." is printed, and "One..." is totally ignored. Seems to be that the first line following the LOOP command, is being skipped? EDIT: It's related to the EXIT DO command. ![]() If I remove the If Inkey$<>"" Then Exit Do line, and change the LOOP line to read Loop Until Inkey$<>"", then the code works! ![]() ![]() Therefore, in my original code posted above, the interpreter is not seeing or otherwise not executing the ON command at all(because it is right after the LOOP command) - and just starts running the next routine below it, which is the database editor routines.... Smoke makes things work. When the smoke gets out, it stops! |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
Try with the exit do back in but put a dummy code line after the loop line. Do . . . Exit do Loop x = x print "one" I don't have any mites upgraded yet. Jim VK7JH MMedit |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
Yes, that does work. I expect that Peter or Geoff will pick up on this and confirm it one way or the other. If any other members have loaded 5.04.07, I would love to know if they are also getting the same result. Smoke makes things work. When the smoke gets out, it stops! |
||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3292 |
Drat. This is the season for adding bugs rather than removing them. I can guess what is causing this. I will get onto it (probably Boxing Day). Geoff Graham - http://geoffg.net |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
No hurry - enjoy your Christmas! I am just happy that this bug is confirmed. I can forget about this bug now, safe in the knowledge that it will be found and squished. ![]() Smoke makes things work. When the smoke gets out, it stops! |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |