11-24-2022, 09:49 PM
(11-24-2022, 07:19 PM)james2464 Wrote: Nice program...the geometry becomes really interesting.
I don't think I've seen OPTION _EXPLICIT before. (Maybe I just didn't notice it yet)
After checking the wiki to see what it's about, I don't really understand. How do I request this for a keyword of the day?
I won't write code without having OPTION _EXPLICIT as my first line of code. As others have pointed out it forces you to declare every variable but I find it handy for another reason as well.
Often times when I'm writing code I'll create lots of variables, or share variables, within my functions and subroutines. As the code progresses some of these variables end up not being used. A quick ' (REM) in front of a declared variable will show if I'm still using it. For example
SUB ThisIsMySUB()
SHARED ThisVariable AS LONG
SHARED ThatVariable AS LONG
DIM AnotherVariable AS INTEGER
DIM YetAnotherVariable AS INTEGER
etc..
When I get close to completing a project and start the process of cleaning the code I can just REM out each SHARED and DIM line individually. The IDE will complain if a variable is in use because OPTION _EXPLICIT is the first line of code. If the IDE complains I know the variable is in use, if no complaints I can safely remove the declaration.
Also, OPTION _EXPLICIT removes the possibility of typos in variable names, the source of many, MANY, a sleepless night debugging.
I highly suggest always using OPTION _EXPLICIT as your first line of code. In fact, I wish the IDE had an option to enable this feature permanently.