Conditional Execution

The script might now be bug-free, but it certainly still has its problems. Consider, for example, what would happen if a user encountering the dialog box “Please enter your age and click OK” decided to submit a nonnumeric answer such as “hibiscus.” VBScript would attempt to add 5 to “hibiscus,” causing a runtime error. Arguably, a user who types hibiscus in response to a question about his age deserves for the script to fail! However, it is the job of a good programmer to anticipate problems that could occur as a result of user interaction with a script by ensuring, for example, that arithmetic calculations are carried out only on numbers. Conditional execution makes this possible by allowing you to choose whether to execute ...

Get Windows Management Instrumentation (WMI) now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.