Class 1 - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

Class 1

Description:

StringVar = 'This is a day in October' DecimalVariable = 3.14159 ... Also watch out for what powerpoint has done to the double quotes! 9/8/09 ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 9
Provided by: JerryBr
Category:
Tags: class | october | quotes

less

Transcript and Presenter's Notes

Title: Class 1


1
Old Business Hand Back Exams
Where we are going from here Learning How to
program Handouts and readings
  • There are many computer languages
  • They have different purposes.
  • What is VBS ? Visual Basic Scripting.
  • Well be operating in several arenas
  • Command Line
  • Editor notepad
  • Code - VBS

2
Command Line Start?Help contains lots of
info about these commands Directory Structures
what are they?? mkdir - create a new
directory cd - move down/up into a
directory Type - show the contents of a file
print it out. Help - tells you more about a
command. Dir - tells you the contents of a
directory. Notepad starts notepad so you can
edit/create a program.
  • Sample Command Line
  • c
  • mMkdir VBS_Dir
  • cd VBS_Dir
  • notepad first.vbs
  • do notepad stuff here ?
  • Try this three ways
  • first.vbs
  • cscript first.vbs
  • wscript first.vbs
  • How do these three ways differ???

Sample Notepad You just start typing. You can
use the mouse to get to the text you want to
change. When youre done typing, do a save. Exit
from notepad in order to continue the scenario on
the left.
Material up to page 25 not too useful!
3
Sample Program I This is a comment line
starting with a quote mark Option
explicit Dim IntegerVariable, StringVar,
DecimalVariable Dim Celsius, Fahrenheit IntegerVa
riable 14 StringVar This is
a day in October DecimalVariable
3.14159 Wscript.echo IntegerVariable, Next
is a string, StringVar, Pi ,
DecimalVariable Converting from Celsius to
Fahrenheit use F ( C 9 )/5 32 Celsius
InputBox( What is the temperature in Celsius
?" ) Fahrenheit ( ( Celsius 9 ) / 5 )
32 Wscript.echo The temperature in Fahrenheit
, Fahrenheit Wscript.quit
Watch out The key leading off a comment is
the character underneath the double quote! Also
watch out for what powerpoint has done to the
double quotes!
4
  • Readings
  • The text in the library is very helpful. Later
    in this document youll find the material well
    cover and where in that text its located.
  • Here is a nice free source of further
    documentation
  • http//msdn.microsoft.com/scripting ? Download ?
  • Microsoft Windows
    Script 5.6 Documentation
  • This could well be MORE than you want to know!!
    You arent really ready for it yet!

5
  • Assignment For Next Class
  • Use notepad to type in Sample Program I and get
    it running. There are often cryptic error
    messages from VBS. These messages are often
    indecipherable, but theyre telling you the
    particular line number where something is wrong.
  • When an error occurs, edit the specified line
    number by comparing it with the text here, and
    fix your code.
  • MODIFY this program. These dont need to be big
    modifications, but you should try other values,
    try some other equation, etc. Be creative.
  • Hand in your code that shows the playing around
    youve done.
  • Use notepad to type in Sample Program II and get
    it running.
  • What does it take to turn this into a game?
    Start thinking about the additional steps needed.

6
Topics To Be Included Here
Computer Languages VBS Pros and Cons. Command
Line notepad Type Dir Makedir Help notepad
Text editor VBS Environment - 10 Using
Hello World - 15 Wscript Cscript Syntax Host
Options Language Essentials 25 REM and
! Variables a is an int, string, or
double Wscript.Echo Wscript.Quit Dim and
Option Explicit 32
How to use comments GUI IO 121 InputBox,
MsgBox Numbers, Strings, Variables
32 Expressions and Assignments 34 X x
1 Operators 35 Arithmetic, String, Comparison,
Logical Parenthesis 39 Program Arguments
30 Sample Program 43 Arrays 44 Control Flow
46 Conditional Statements If 47 If then
else 48 If then elseif .. else .. 48 If
then .. end if - 48
7
Topics To Be Included Here
Loops Do while Loop 50 Do Until Loop
52 Do Loop while 53 Exit Do 54
While Wend 55 For Next 56 Select
62 Variables Naming Restrictions
74 Types Numbers 70 72 Date 72 String
75 Const 77 String Functions -
100 Len Left Right Mid InStr Split
8
Sample Program II 1. '
2
. ' 3. ' This is the game "Pick the last coin" 4.
' 5. '
6. Option
Explicit 7. Dim StartingNumberOfCoins,
MaxPerTurn, WhoGoesFirst 8. 9. WScript.Echo "This
is a game pitting you against the
computer." 10.WScript.Echo "The object is to pick
up the last coin." 11. 12.StartingNumberOfCoins
InputBox( "How many coins do you want to start
with?" ) 13.MaxPerTurn InputBox( "What's the
max coins you can take on a turn?"
) 14.WhoGoesFirst MsgBox( "Do You Want To Go
First?", 4 ) 15. 16.WScript.Echo "Starting Coins
", StartingNumberOfCoins, " Max Per Turn ",
MaxPerTurn 17.If ( WhoGoesFirst vbYes )then
WScript.Echo "You go first." 18.If ( WhoGoesFirst
vbNo )then WScript.Echo "I go
first." 19.WScript.Quit
Dont type in the line numbers!!
Write a Comment
User Comments (0)
About PowerShow.com