06-03-2023, 01:51 PM
@Dimster Where Option _Explicit really shines is when you make a simple typo in your 10,000+ lines of code.
Let's say we have a variable like so:
DIM cheetos AS _Byte
Now, we write a line of code like so:
cheetos = (cheotes + 1) Mod 2
Now, is the syntax checker going to find anything wrong with that line of code?
NOPE! It's perfectly valid code!
Are YOU going to be able to see that you misspelled that word at 2AM in the morning, when you finally compile it and start getting unexpected results from the program? Or is your poor eyes going to just glaze over it as you scan your code and look for mistakes, skipping line 9213 repeatedly as your scroll from lines 1 to 11423 looking for a glitch??
A lot of times, the answer is: NOPE!! <--This is one of the most common type programmer errors, and one of the hardest to self-diagnose and correct. We *KNOW* what should be correct. Our brains tells us what should be correct. And our eyes just glaze over when skimming and assume that we're correct -- even if we're not.
Option _Explicit would save you a lot of hair pulling and frustration in this instance. The moment you type CHEOTES instead of CHEETOS, it'll scream at you: RAHHR!!! YOU NEVER DEFINED THAT VARIABLE!! BAD BOY!! BAD, BAD BOY!!! RAHHHHHRRRRRRR!!!!
Well... It might be a little more polite than that -- I wouldn't know, as I'm always a perfect coder and never make such mistakes and as such never have to use Option _Explicit to find any glitches in my perfect code.
Let's say we have a variable like so:
DIM cheetos AS _Byte
Now, we write a line of code like so:
cheetos = (cheotes + 1) Mod 2
Now, is the syntax checker going to find anything wrong with that line of code?
NOPE! It's perfectly valid code!
Are YOU going to be able to see that you misspelled that word at 2AM in the morning, when you finally compile it and start getting unexpected results from the program? Or is your poor eyes going to just glaze over it as you scan your code and look for mistakes, skipping line 9213 repeatedly as your scroll from lines 1 to 11423 looking for a glitch??
A lot of times, the answer is: NOPE!! <--This is one of the most common type programmer errors, and one of the hardest to self-diagnose and correct. We *KNOW* what should be correct. Our brains tells us what should be correct. And our eyes just glaze over when skimming and assume that we're correct -- even if we're not.
Option _Explicit would save you a lot of hair pulling and frustration in this instance. The moment you type CHEOTES instead of CHEETOS, it'll scream at you: RAHHR!!! YOU NEVER DEFINED THAT VARIABLE!! BAD BOY!! BAD, BAD BOY!!! RAHHHHHRRRRRRR!!!!
Well... It might be a little more polite than that -- I wouldn't know, as I'm always a perfect coder and never make such mistakes and as such never have to use Option _Explicit to find any glitches in my perfect code.