1 / 21

CN2180 Chapter 1

CN2180 Chapter 1. Kemtis Kunanuraksapong MSIS with Distinction, A+ MCTS, MCDST, MCP. Agenda. Introduction to programming Basic Flow Chart Basic Pseudo code Introduction to WSH and VBScript Assignment. Introduction to programming. What is flowchart? Why we need it?

goldy
Download Presentation

CN2180 Chapter 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CN2180Chapter 1 Kemtis Kunanuraksapong MSIS with Distinction, A+ MCTS, MCDST, MCP

  2. Agenda • Introduction to programming • Basic Flow Chart • Basic Pseudo code • Introduction to WSH and VBScript • Assignment

  3. Introduction to programming • What is flowchart? • Why we need it? • What does it look like?

  4. Basic flow chart • Start / Stop (End) • Process • Condition (Yes / No) • Input • Display

  5. Basic flow chart (cont.) Start How are you? input yes No =“good”? X = “Excellent!” X = “I’m sorry” ‘X’ Stop

  6. Basic Pseudo code • What is Pseudo code? • Why we need it? • What does it look like?

  7. Basic Pseudo code (Cont.) • Start • Ask user, “How are you” • Take input from user • If input = “good” then • X := “Excellent!” • Else • X := “I’m sorry” • Display “X” • Stop

  8. Exercise • Write a flow chart and pseudo code for • Grading system • Take input from user • Show A, if input is greater than or equal to 90

  9. Introduction to WSH • Windows Script Host (WSH) • Run on MS Windows • Small text based file • WSH Components • Script Engines • Script execution hosts • The WSH core object model • See Figure 1.5 on page 5

  10. WSH Scripting Engines • Script execution engine • VBScript • Jscript • 3rd party script engines such as Perl, Python, and Rexx.

  11. WSH Script Execution Host • CScript.exe • WScript.exe • Which one you should use? • Required user interaction?

  12. WSH Core Object Model • It provides VBScript with direct access to Windows resources • Windows desktop • Windows Start menu • Windows applications • Windows file system

  13. Object, Method, and Properties • What is an Object? • Object has method and properties • IE. Box is an object • Box’s method are put it in, take it out, re-arrange • Box’s properties are height, width, water resistance, etc

  14. First VBScript • Type : MsgBox “Hello World!” • Save it as hello.vbs • By default, windows use wscript.exe to execution host

  15. First VBScript (Cont.) • MsgBox() function is a built-in VBScript function • Modified the code to: Set WshShl = Wscript.CreateObject(“Wscript.Shell”) WshShl.Popup “Hello World!”

  16. First VBScript (Cont.) • Set is to define a variable named WshShl with a value Wscript.CreateObject(“Wscript.Shell”) • CreateObject method is used to instantiate the WshShell object. • Popup() method is to display a pop-up dialog

  17. First VBScript (Cont.) • Modified the code: WScript.Echo “Hello World” • Echo() method is to display a text message. • Tried with both WScript and CScript.

  18. Knock Knock Game • Designing the game: • Knock Knock! -> Who’s There • Panther -> Panther who? • Panther no panths, I’m going swimming • Error message should be displayed if answered wrong

  19. Knock Knock Game (Cont.) • Write pseudo code or draw flow chart • Do the code.

  20. Knock Knock Game (Cont.) Reply1 = InputBox(“Knock Knock!”) If Reply1 = “Who’s there?” Then Reply2 = InputBox(“Panther!”) If Reply2 = “Panther who?” Then MsgBox “Panther no panths I’m going swimming.” If Reply2 <> “Panther who?” Then MsgBox “Incorrect answer. Try again.” End if If Reply1 <> “Who’s there?” Then MsgBox “Incorrect answer. Try again.”

  21. Assignment • P29 Challenges #3 • Write a script to take input (name and grade) from user then use message box to show name, grade, and grade letter.

More Related