program crashes about 20% of the time
#13
(12-18-2022, 06:50 PM)mdijkens Wrote: This really looks like it started as Basic, then migrated to qbasic then to qb64...
Done this a few times myself.
Always start refactoring code to remove goto and gosub and localize variables with strong typing. 
It takes some time, but you win that back in the long run....

No need to get rid of "GOTO" and "GOSUB... RETURN" but have to keep track of it carefully. Please don't make QB64(PE) more like Freebasic and Visual Basic for some people.

"ON... GOTO" and "ON... GOSUB" have a way to induce bad habits too. I agree those should be replaced by "SELECT CASE... END SELECT" which is far more readable and easier to control.

A programmer who cannot decide between "GOTO" and "GOSUB" to jump around in code should stop insisting on it. Put the "subroutine" block into a subprogram that could be called by name. Because using "GOSUB" must have a "RETURN" around somewhere. Please remember that in Q(uick)BASIC, and later on in QB64(PE) line numbers are not required, and therefore there is no sense in programming as if the opposite were true. Cannot hate "RETURN without GOSUB" interpreter error message that much as an excuse not to force "subroutines" to be self-contained, or as an excuse to not create subprograms of any kind.

I agree with the strong typing except for people very used to implicit declarations of variables. Again, things have to be examined more carefully because it's left entirely at the programmer's disposal. "OPTION _EXPLICIT" could only do so much, and some coders have a problem with it.
Reply


Messages In This Thread
RE: program crashes about 20% of the time - by mnrvovrfc - 12-18-2022, 07:23 PM



Users browsing this thread: 8 Guest(s)