If...Then
If...Then is one of those programming staples (like fried chicken and mashed potatoes are staples in the southern United States). What’s nice about If...Then is that it makes sense. We use this kind of logic all the time.
The basic operation is diagrammed here:
If | condition | Then | action |
---|---|---|---|
If | store is open | Then | buy chicken |
The real power of If...Then comes into play when combined with tools such as those we looked at in Chapter 2. If...Then is rarely used by itself. Although you could have a script such as this one, you wouldn’t find it extremely valuable:
Const a = 2 Const b = 3 Const c = 5 If a + b = c Then WScript.Echo(c) End If
In this script are defined three constants: a, b, and c. We then sum the numbers and evaluate the result by using the ...
Get Microsoft® Windows® Scripting Self-Paced Learning Guide 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.