Comp230 W5

Submitted by: Submitted by

Views: 391

Words: 1831

Pages: 8

Category: Science and Technology

Date Submitted: 09/22/2013 09:52 AM

Report This Essay

VBScript Modular Programming Lab

Objective

In this lab, students will complete the following objectives:

* create a VBScript program using NotePad++;

* use procedures to modularize a VBScript program;

* create a library of procedures; and

* run library procedures from a separate VBScript program.

Task 1: Download PC Test VBScripts to C:\VBScripts\

In Doc Sharing, download the zip file PC_Tests.zip. Extract the files from the zip file into your C:\VBScripts\ folder. If this folder does not exist, create the folder and complete the extraction of the files to this folder.

Verify that the C:\VBScripts folder contains the following extracted files: PC_Tests.vbs and PC_Tests.cmd.

Task 2: Analyze the Batch Script File PC_Tests.cmd

One of the drawbacks to using VBScript instead of a full-featured programming language, such as C++ or Java, is the fact that VBScript and JScript must be run using the Windows Scripting Host instead of running as a standalone executable. One of the things we need to do with our menu-driven, PC_Tests program is clear the screen each time the menu is redisplayed. Because we can’t do this is VBScript, we will do it in a batch-script file. Look at the PC_Tests.cmd batch script shown below. The script performs the following tasks: (1) it clears the screen (CLS), (2) it displays the menu, (3) it prompts the user and stores the input into choice, (4) it uses cscript to run the PC_Tests.vbs program and sends it the choice value (1-5) as an argument (//nologo hides the scripting host heading), (5) it executes a pause when the PC_Tests.vbs program exits and returns to the batch script, and (6) it goes to the beginning of the script to clear the screen and redisplay the menu after the user presses a key to end the pause. A sample batch-script Run is shown below.

Task 3: Analyze the Code in the PC_Tests.vbs Program

* Open the PC_Tests.vbs program in NotePad++. Let’s review some code that can tell us many...