Author Topic: "option explicit" - does it work?  (Read 3271 times)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
"option explicit" - does it work?
« on: December 06, 2018, 03:18:08 pm »
Being careful coders, we put option explicit at the top of each VBScript.

We had a weird bug today which we traced down to an undefined variable name NOT being picked up by the option explicit setting.

Code: [Select]
option explicit
dim GoodOne
GoodOne = 10
BadOne = 20
should fail on the second assignment, but doesn't.

We've discovered that if in Debug mode, the option explicit functionality DOESN'T WORK!

So to check for option explicit you need to run the script in a normal manner.

"It's a bug, !"

Reported,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: "option explicit" - does it work?
« Reply #1 on: December 06, 2018, 03:46:25 pm »
Yeah, ran into that one a couple of times as well.
If you forget to test your script in "run" mode and ship it like that you get complaints from the users saying the script won't work.
Makes you look like a fool. :-\

Geert