Free Essay

Comp230 W2 Lab

In:

Submitted By dd11388
Words 1091
Pages 5
Student Name | xx | Class | COMP-230 | Date | 9-2012 | VBScript IPO VBox Lab Report ' VBScript: NameAge.vbs
' Written by: xx
' Date: 9-2012
' Class: Comp230
' Professor:xx
' Create name and age variables

name = "" ageStr = ""
' Promt User for Name and Age
WScript.StdOut.Write("Please Enter your Full Name ") name = WScript.StdIn.ReadLine()
Wscript.StdOut.WriteLine() 'Skip 1 Line
WScript.StdOut.WriteLine("Please Enter your age ") ageStr = WScript.StdIn.ReadLine() ageStr10 = CStr( CInt(ageStr)+10 )
' Display Name and age Value
WScript.StdOut.WriteBlankLines(2) 'Skip 2 Lines
WScript.StdOut.WriteLine("Your Name is " & vbtab & vbtab & name)
WScript.StdOut.WriteLine("Your Age is " & vbtab & vbtab & ageStr)
WScript.StdOut.WriteLine("Your Age in 10 years is ......" & _ AgeStr10 & vbcrlf) WScript.StdOut.WriteLine("End of Program")
' VBScript: NameAge.vbs
' Written by: xx
' Date: 9-2012
' Class: Comp230
' Professor:xx
' Create name and age variables

name = "" ageStr = ""
' Promt User for Name and Age
WScript.StdOut.Write("Please Enter your Full Name ") name = WScript.StdIn.ReadLine()
Wscript.StdOut.WriteLine() 'Skip 1 Line
WScript.StdOut.WriteLine("Please Enter your age ") ageStr = WScript.StdIn.ReadLine() ageStr10 = CStr( CInt(ageStr)+10 )
' Display Name and age Value
WScript.StdOut.WriteBlankLines(2) 'Skip 2 Lines
WScript.StdOut.WriteLine("Your Name is " & vbtab & vbtab & name)
WScript.StdOut.WriteLine("Your Age is " & vbtab & vbtab & ageStr)
WScript.StdOut.WriteLine("Your Age in 10 years is ......" & _ AgeStr10 & vbcrlf) WScript.StdOut.WriteLine("End of Program")
Copy your NameAge.vbs program from NotePad++ and paste it into the space provided below:.

Capture the NameAge.vbs Run from the console window and copy it into the space provided below: cscript NameAge.vbs
Process started >>>
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

Please Enter your Full Name xx

Please Enter your age
24

Your Name is xx
Your Age is 24
Your Age in 10 years is ......34

End of Program
<<< Process finished. cscript NameAge.vbs
Process started >>>
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

Please Enter your Full Name xx

Please Enter your age
24

Your Name is xx
Your Age is 24
Your Age in 10 years is ......34

End of Program
<<< Process finished.

' VBScript: NameAge.vbs
' Written by: xx
' Date: 9-2012
' Class: Comp230
' Professor: xx
' create name and age variables

name = "Jon Doe" ageStr = "50"

ageStr10 = CStr( CInt(ageStr)+10 )
' Build output as a single string msgSttr msgStr = "Your Name is " & vbtab & vbtab & name & _ vbcrlf & "Your Age is " & vbtab & vbtab & ageStr & _ vbcrlf & vbclrf & "Your Age in 10 years is " & vbtab & _ AgeStr10 & vbcrlf & vbcrlf & "End of Program" ' One Echo Statement for all output WScript.Echo msgStr
' VBScript: NameAge.vbs
' Written by: xx
' Date: 9-2012
' Class: Comp230
' Professor: xx
' create name and age variables

name = "Jon Doe" ageStr = "50"

ageStr10 = CStr( CInt(ageStr)+10 )
' Build output as a single string msgSttr msgStr = "Your Name is " & vbtab & vbtab & name & _ vbcrlf & "Your Age is " & vbtab & vbtab & ageStr & _ vbcrlf & vbclrf & "Your Age in 10 years is " & vbtab & _ AgeStr10 & vbcrlf & vbcrlf & "End of Program" ' One Echo Statement for all output WScript.Echo msgStr
Copy your PopUpWindow.vbs program from NotePad++ and paste it into the space provided below:

Capture the PopUpWindow.vbs Run (using <Alt><PrtSc> to capture the PopUp Window on the desktop) and copy it into the space provided below:
' VBScript: NameAge.vbs
' Written by: xx
' Date: 9-2012
' Class: Comp230
' Professor: xx

'Check for Command Line Arguments
Set args = WScript.Arguments
If args.count < 2 then WScript.echo "You must enter the name and age as Command Line Argument!!" WScript.Sleep(5000) WScript.Quit end If ' Assign name and age variable to Cmd Line Args name = args.item(0) ageStr = args.item(1)
'calculate Age+10 and assign to ageStr10 ageStr10 = CStr( CInt(ageStr)+10 )
' Build output as a single string msgSttr msgStr = "Your Name is " & vbtab & vbtab & name & _ vbcrlf & "Your Age is " & vbtab & vbtab & ageStr & _ vbcrlf & vbclrf & "Your Age in 10 years is " & vbtab & _ ageStr10 & vbcrlf & vbcrlf & "End of Program" ' One Echo Statement for all output WScript.Echo msgStr
' VBScript: NameAge.vbs
' Written by: xx
' Date: 9-2012
' Class: Comp230
' Professor: xx

'Check for Command Line Arguments
Set args = WScript.Arguments
If args.count < 2 then WScript.echo "You must enter the name and age as Command Line Argument!!" WScript.Sleep(5000) WScript.Quit end If ' Assign name and age variable to Cmd Line Args name = args.item(0) ageStr = args.item(1)
'calculate Age+10 and assign to ageStr10 ageStr10 = CStr( CInt(ageStr)+10 )
' Build output as a single string msgSttr msgStr = "Your Name is " & vbtab & vbtab & name & _ vbcrlf & "Your Age is " & vbtab & vbtab & ageStr & _ vbcrlf & vbclrf & "Your Age in 10 years is " & vbtab & _ ageStr10 & vbcrlf & vbcrlf & "End of Program" ' One Echo Statement for all output WScript.Echo msgStr Copy your CmdArgs.vbs program from NotePad++ and paste it into the space provided below:

C:\Scripts>cscript CmdArgs.vbs
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

You must enter the name and age as Command Line Argument!!

C:\Scripts>cscript CmdArgs.vbs "xx" 24
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

Your Name is xx
Your Age is 24
Your Age in 10 years is 34

End of Program
C:\Scripts>cscript CmdArgs.vbs
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

You must enter the name and age as Command Line Argument!!

C:\Scripts>cscript CmdArgs.vbs "xx" 24
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

Your Name is xx
Your Age is 24
Your Age in 10 years is 34

End of Program
Capture the two CmdArgs.vbs console Runs (one without arguments and one using your name and age as arguments) and copy the runs into the space provided below:

Similar Documents