No need to shunt around an error handler with something like "GOTO beginning" when it is used in this fashion. Also, it is an exception of GOTO where the developers made it possible to place the error handler in the main, while allowing ON ERROR GOTO to be placed in subs. The only complaint I had (back in the day) was in multi-modular programming, one had to make an error handler for each module. There was no way to make a universal error handler back then. Nowadays, multi-modular programming is completely unnecessary.
Pete
Title: Re: ON ERROR THEN
Post by: Jaze on September 08, 2021, 11:20:40 am
Looking at what was said about me going around the error portion with "GOTO beginning". If I took out the label and the GOTO would the ide simply pass the ERROR label? How exactly should that work? Btw, didn't know ON ERROR could be used in a SUB, so thanks for that.
Title: Re: ON ERROR THEN
Post by: Qwerkey on September 09, 2021, 04:45:58 am
I agree with Steve. I hate using ON ERROR GOTO which requires the two labels and code stepping over each other. A hand-me-down from QB2 (or the original BASIC?).
When the team have come up with the new ON ERROR THEN, could we have it with an ELSE as well:
ON ERROR THEN
PRINT "Point out to that idiot Qwerkey that he has made yet another stupid error in his code." PRINT "Why did we ever let this fool anywhere near QB64?" PRINT ERR, _ERRORLINE
ELSE
' Carry on with the rest of Qwerkey's amazing Masterwork of efficiently written QB64 code.
END ON ERROR
Title: Re: ON ERROR THEN
Post by: bplus on September 09, 2021, 12:18:05 pm
2. I have seen code with ON ERROR GOTO to manage issues like File not found, VideoMode not avaiable indeed illegal funtion call for a graphic statement , out of DATA, Subscritpt Out of Range. For many of these we have specific _QB64 _Keywords to verify to avoid the error on fly.
3. the GOTO /RESUME / RESUME NEXT(Yeah only QB PDS) is an haitful old fashioned structure. But it works! Yes I would prefer ON ERROR THEN (one line statement without ELSE or END ON ERROR but just the first primitive IF...THEN) to call directly the sub managing the error, so the code to manage can be used also in a recursive way but to get this I must only put the name of SUB just between ErrorLabel: and RESUME
Why don't like multiple lines ON ERROR THEN? Because in a sub you can put as many as statements and controls you want to have. So we can do that without developing more keywords.