Timer Trap Problem - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: Timer Trap Problem (/showthread.php?tid=3111) |
Timer Trap Problem - eoredson - 10-09-2024 Hi, This code does not work: Code: (Select All)
RE: Timer Trap Problem - SMcNeill - 10-09-2024 Simply return from your timer: Code: (Select All)
RE: Timer Trap Problem - eoredson - 10-09-2024 That obviously solves the code snippet I posted, however, the reason why I need it to return to a line label is because I am writing a large program trapping control-break with _exit which prompts Quit/Resume and since the do/loop has 100 lines I don't want to return to somewhere inside the loop, only to the top of the loop.. Erik. is what I just said more clear?? RE: Timer Trap Problem - SMcNeill - 10-09-2024 Erik, don't take this the wrong way, but that's about the worst idea I think I've ever heard of from a programmer. On Timer can occur at ANY point inside your code. You could have executed 10 lines of your code and went to the On Timer. You could have executed 40 lines of your code and went to the On Timer. As for you next 60 lines of code? PAH!! You may as well cut them out of the damn program, as your On Timer triggers and stops execution from ever getting to them. Oh, maybe not on YOUR PC, but on Pete's old slow one? Or how about if your PC has a heavy workload and is running slow? You don't know where the heck that event was called from, or how deep into your program things might run before it triggers. The idea of On Timer is "skip out, do something, skip back..." What you're suggesting is "skip out, do something, go someplace completely unrelated". If that's what you're wanting to do, set up your code to do it with a flag or something: Code: (Select All)
Return label just isn't designed to work like that with ON TIMER. and it never should be. RE: Timer Trap Problem - eoredson - 10-09-2024 Ok, thanks for the feedback. Figures the only way to solve the problem is to add a flag... Which is what I am already doing with a ControlBreak flag. I guess it was never meant to be. Erik. RE: Timer Trap Problem - eoredson - 10-09-2024 The actual code to trap Control-Break I am using is posted here: Code: (Select All)
RE: Timer Trap Problem - ahenry3068 - 10-09-2024 (10-09-2024, 03:37 AM)eoredson Wrote: The actual code to trap Control-Break I am using is posted here:That seems like a lot of code for nothing. Once _exit is called once then Ctrl/Break and "click the X" is trapped. _exit returns the counts. I just check _exit in an ON TIMER and set a flag variable. I check that flag variable in my main program loop and set the behavior as if a User had selected my normal program Exit option. Often that involves asking "Really want to Quit Y/N " I think it's pretty important especially if you want your program to clean up any temporary files it might have created and/or return to the directory it started in if you may have changed directory's within the program. RE: Timer Trap Problem - Cobalt - 10-09-2024 Why not just throw an Code: (Select All)
in the loop. Why use an ON TIMER to begin with? RE: Timer Trap Problem - bplus - 10-09-2024 (10-09-2024, 03:42 PM)Cobalt Wrote: Why not just throw an It's used in the example for _Exit in Wiki. RE: Timer Trap Problem - eoredson - 10-10-2024 (10-09-2024, 03:42 PM)Cobalt Wrote: Why not just throw anBecause break checking is being done in dozens of Sub/Functions and they cannot goto a line label in the main body of code. It's just easier to trap the break and/or use a flag.. btw: be careful because Ctrl-Break will also put Ctrl-C into Inkey$ |