Previous Section Table of Contents Next Section

Chapter 10. Controlling the Flow of Execution

IN THIS CHAPTER

You've learned almost everything you need to know to write great scripts. The last step in your VBScript crash course is to add complexity and logic to your scripts by using control-of-flow constructs.

At this point, you should know enough VBScript to write some useful administrative scripts. In fact, the previous few chapters contained some great example scripts that you should be able to put right to use, in addition to using them as reference examples.

What you lack at this point, and what I'll cover in this chapter, is a way to make your scripts automatically respond to certain conditions, and execute different lines of script accordingly. For example, suppose you need to write a script that tells you which user has a particular file open on a file server. Your script must be able to iterate through all of the open resources on a server to find the one you're interested in, and then iterate through the list of users that have the resource open, displaying that information to you. Such a script would require certain lines of code to be repeated over and over, while requiring other lines of code to be executed only if certain conditions are true (such as if the current server resource is the one you're interested in).

VBScript includes control-of-flow statements that give your scripts the necessary logical-evaluation capabilities. In this chapter, you'll learn how they work, and see some examples of how to use them in your scripts.

    Previous Section Table of Contents Next Section