Previous Section Table of Contents Next Section

Chapter 5. Functions, Objects, Variables, and More

IN THIS CHAPTER

You've learned how to design a script, but you're not quite ready to write one. First, you have to learn the basics of VBScript, and this chapter begins your crash course.

Scripting is, of course, a form of computer programming, and computer programming is all about telling a computer what to do. Before you can start ordering the computer around, though, you need to learn to speak a language that it understands. VBScript is one such language, and in this chapter, I'll introduce you to the VBScript syntax, or language.

Almost all computer programming languages, including VBScript, have a few things in common.

  • They have built-in commands that tell the computer to perform certain tasks or calculate certain kinds of information.

  • They have a means for tracking temporary information, such as data entered by a user or collected during some calculation.

  • Windows-based programming languages generally have a means for interacting with objects, because objects form the basis of Windows' functionality.

NOTE

The capability to interact with objects is not the same thing as being an object-oriented programming language. Although the concepts and benefits of object-oriented programming are beyond the scope of this book, suffice to say that VBScript isn't object oriented, despite its capability to interact with objects created in other languages.


VBScript implements these common programming elements through variables, functions, and statements, and through an object interface.

  • Variables act as storage areas for different types of data.

  • Functions are VBScript's way of performing calculations or tasks and providing you with the results; statements simply perform tasks. You can even create your own functions and statements to customize VBScript's capabilities.

  • VBScript includes a complete object interface based on Microsoft's Component Object Model, or COM.

In this chapter, you'll learn how to use each of these elements within scripts.

NOTE

I've never liked programming books that provide short, useless snippets of script as examples, even as early in the book as you are right now. Most of the examples you'll see in this and subsequent chapters are fully functioning scripts that you can actually use in your environment. Of course, to make them fully functioning, they have to include some things that you won't learn about until later chapters. That's OK; I'll point out the parts of the scripts that are important for now, and as you read through the next few chapters in Part II, you'll learn more and more about how these scripts operate.


    Previous Section Table of Contents Next Section