SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 713 | Next

David A. Karp

"Windows Vista Annoyances: Tips, Secrets, and Hacks"


Build a VBScript Script | 521
Scripting and
Automation
A function is essentially the same as a subroutine, except that it has a result,
called a return value. Both subroutines and functions accept input variables,
listed in parentheses after the respective Sub and Function statements.
To those who are familiar with macros in a word processor,
subroutines are similar. In fact, Microsoft Word, Excel, and
Access (in Office 95 and later) save their macros as VBScript
subroutines.
Consider Example 9-1, which compares the contents of two text files. At the
heart of this example are the two structures at the end of the script, although
their specific position in the script is not important. WSH separates all subroutines
and functions before executing the script; they won??™t be executed
unless they??™re called, and the variables used therein are unrelated to variables
used elsewhere in the main script. Whenever it encounters the name
of a subroutine or function in the script body, it executes it as though it
were a separate script. Try to follow the execution of the script, command
by command.
One of the most important aspects of both subroutines and functions is that
they can accept one or more input variables, called parameters or arguments.
The parameters that a subroutine can accept are listed in parentheses after the
subroutine definition and are separated by commas (if there??™s more than one).
Example 9-1. Using functions and subroutines
Filename1 = InputBox("Enter the first filename")
Filename2 = InputBox("Enter the second filename")
If Not FileExists(Filename1) Then
MsgBox Filename1 & " does not exist.


Pages:
701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6