COMP230 Week 2 Lab VBScript Input/Process/Output Lab
Download here: http://homeworkfox.com/questions/computer-science/11713/comp23
accomplished in a single code line? · Let’s skip two lines and display the user’s name and age, The WriteBlankLines( ) method is used to skip two lines and the WriteLine( ) method displays our text output to the console window and sends a <newline> at the end to move the cursor to the beginning of the next line. The & symbol is used to add multiple strings together. The vbTab is a tab character that moves the cursor to the next horizontal tab position to help line up data. · Now we need to display the value for the user’s age in 10 years. Below are the remaining lines of our program. At the end of the first line, notice the & _. The _ is the line continuation character. The rest of the WriteLine statement is continued on the next line. This continued line contains ageStr10 variable & vbCrLf. · Save your program (<Ctrl>S). Press the <F6> function key and enter: cscript NameAge.vbs. Click OK to run your program. Your program will run in the NotePad++ console window. Note: You need to click within the NotePad++ console window so you can enter the name and age values. A sample RUN of the completed program is shown below. The user is prompted for their full name and age. After receiving this data input from the keyboard, two blank lines are displayed and the user’s full nameand age values are displayed. After skipping one more line, the user’s age in 10 years will be calculated and displayed. After one more skipped line, the End of Program message is displayed. · If you prefer, you can open the Windows CLI and run the program directly from the command prompt as shown below. · Before we exit this program and begin the next one, let’s explore the limitations of using the StdIn and StdOut streams. Press <F5> and edit the “The Program to Run” to read wscript C:\Scripts\StdinStdout.vbs.Wscript is supposed to send output to a pop-up window on the desktop. Click Run and let’s see what happens. You should have received the error message shown below. Bottom line, StdIn and StdOut streams only work for console programs only. Note: When using <F5> (Run), the entire path to the script must be included. The complete path is not required when using <F6> (Execute). The reason we didn’t use <F6> for this test is because all standard input (StdIn) and standard output (StdOut) uses the built-in NotePad++ console window instead of unsuccessfully trying to send it to a desktop window. Running the NameAge.vbs program from the Windows CLI with wscript will generate the same error as shown below.
Task 3: PopUpWindow.vbs Script using WScript.Echo for output
· We are going to use the NameAge.vbs as a starting point for our next program. Save As your NameAge.vbs program with the name PopUpWindow.vbs. · Change the variable definition lines for name and AgeStr to