... follows the backslash. In this case, the
next character is the character
n. Together, the backslash (\) and n characters make up an
escape sequence.
Escape Sequences
This particular escape sequence ... escape characters or escape sequences. The backslash
character (
\) is the escape character. When the printf() statement shown above is executed,
the program looks forward to the next character ... printf(" the \\n and \\\\ escape sequences");
}
18
C ProgrammingfortheAbsolute Beginner, Second Edition
/* CProgrammingfortheAbsoluteBeginner */
//by Michael Vine
#include <stdio.h>
...
... through the ASCII (American Standard Code for
Information Interchange) character set. For a listing of common ASCII character codes, see
Appendix D, “Common ASCII Character Codes.”
ASCII
ASCII
... known as character codes. For exam-
ple, the character code 90 represents the letter Z. Note that the letter Z is not the same as the
character code 122, which represents the letter z (lowercase ... known
as conversion specifiers.
Conversion specifiers are comprised of two characters: The first character is the percent
sign (
%
), and the second is a special character that tells the program...
... occurred because after the appropriate
case
statement is matched to the
switch
variable, the
switch
structure continues processing each
case
statement thereafter.
72
C Programmingforthe ... 'a' )
Checking for a Range of Values
Checking for a range of values is a common programming practice for input validation. You
can use compound conditions and relational operators to check for ... ProgrammingfortheAbsolute Beginner, Second Edition
To correct this, use the
srand()
function, which produces a true randomization of numbers.
More specifically, the
srand()
function tells the...
... 238
x
Microsoft WSH and VBScript ProgrammingfortheAbsolute Beginner, Second Edition
How This Book Is Organized
The second edition of
Microsoft WSH and VBScript ProgrammingfortheAbsolute Beginner
has ... . . . . . . . . . . . . . . . . . . .487
xiv
Microsoft WSH and VBScript ProgrammingfortheAbsolute Beginner, Second Edition
Back to the Tic-Tac-Toe Game . . . . . . . . . . . . . . . . . . ... of the WSH woven throughout these
chapters. Part III’s five chapters, including the two new chapters, are dedicated to covering a
collection of advanced topics that include file and folder administration,...
... prompt.
Introducing the WSH Core Object Model
The WSH provides one final component, called the core object model, which is critically
important to the development and execution of scripts. The WSH core object ... shows the message that appears if the player does not play the game correctly.
Microsoft WSH and VBScript ProgrammingfortheAbsolute Beginner, Second Edition
Figure 1.1
The game begins
by knocking ... choose
one over the other. For example, if you plan to run
Microsoft WSH and VBScript ProgrammingfortheAbsolute Beginner, Second Edition
Definition
Within the context of this discus-
sion, the term...
... File object that
specifically refers to
Sample.txt, which is located in the computer C: \Temp folder.
The main processing of the script then makes a series of procedure calls. The
CreateDisplay
String()
function ...
Sample.txt, which resides in the Temp directory on the com-
puter’s C: drive. If the file exists, the script opens it. If the file doesn’t already exist, the
script creates it. Once opened, the script ... strDisplayString
Microsoft WSH and VBScript ProgrammingfortheAbsolute Beginner, Second Edition
By the time you’ve completed this chapter and created the Lucky Lottery Number Picker
game, you...
... pairs
have been defined.
Microsoft WSH and VBScript ProgrammingfortheAbsolute Beginner, Second Edition
256
Microsoft WSH and VBScript ProgrammingfortheAbsolute Beginner, Second Edition
Mid(strInput, ... 258
Designing the Game
In total, the script will consist of 10 functions, each of which is designed to perform a
specific task. The names of these 10 functions and the tasks they perform are
ã
SetVariableDefaults()
.
Establishes ... at the following example, which deletes a folder named
Temp that is located
within the
C: \VBScriptGames folder.
TRICK
Microsoft WSH and VBScript ProgrammingfortheAbsolute Beginner, Second...
... to continue?”, 4)
‘Call the function that collects CPU information
If intResponse = 6 Then
GetProcessorInfo()
End If
WScript.Quit()
‘Procedure Section
Function GetProcessorInfo()
‘Get the processor ... objWshShell = WScript.CreateObject(“WScript.Shell”)
objWshShell.RegWrite “HKCU\GameKey\HomeFolder”, C: \MyGames\VBScript”
TRAP
Microsoft WSH and VBScript ProgrammingfortheAbsolute Beginner, Second Edition
... Section defines its variables and instantiates the WshShell object.
The Main Processing Section prompts the user for confirmation before continuing, and then
calls the
GetProcessorInfo() function...
... another source
of data input for your VBScripts.
Microsoft WSH and VBScript ProgrammingfortheAbsolute Beginner, Second Edition
C HALLENGES
1. Create new collection of word files to increase the ... have access to a small
collection of built-in or core objects. Using these built-in VBScript objects, you
can create scripts that react to errors, create their own custom objects, and per-
form ... collection of built-in objects. The VBScript interpreter provides
access to these objects. Therefore, they are available to any VBScript regardless of the exe-
cution host running it. This collection...
... all of the code is to be placed in the Click() event
procedure of the Command Button control. The code window can be accessed via
the VBA IDE by double-clicking on the Command Button control while ... the cells is chosen randomly and will change with each click
of the Command Button control because the above code will run once with each
click event. So the entire procedure now looks like the ... functions. Excel then calls the function procedure
AVERAGE()
and passes the range of values specified in parentheses—in this case, nine values.
The function procedure
AVERAGE() then calculates...