VBScript Language. What is VBScript Based on the Visual Basic family of languages Supports object oriented features Interpreted Loosely Typed Implicitly.

Slides:



Advertisements
Similar presentations
Week 6 - Programming I So far, we’ve looked at simple programming via “scripts” = programs of sequentially evaluated commands Today, extend features to:
Advertisements

Control Structures Control structures are used to manage the order in which statements in computer programs will be executed Three different approaches.
Chapter 5 Decisions. Outline and Objectives Relational and Logical Operators If Blocks Select Case Blocks.
Chapter 4 Control Structures I. Objectives ► Examine relational and logical operators ► Explore how to form and evaluate logical (Boolean) expressions.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
10 November JavaScript. Presentation Hints What do YOU think makes a good presentation Some of my suggestions Don’t write full sentences on slides Talk,
Logical Operators Java provides two binary logical operators (&& and ||) that are used to combine boolean expressions. Java also provides one unary (!)
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Conditional Statements Control Structures.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie June 27, 2005.
JavaScript, Fourth Edition
Chapter 2: Introduction to C++.
ASP.NET Programming with C# and SQL Server First Edition
JavaScript, Third Edition
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements II.
VB .NET Programming Fundamentals
CONTROL STATEMENTS Lakhbir Singh(Lect.IT) S.R.S.G.P.C.G. Ludhiana.
Fundamentals of Python: From First Programs Through Data Structures
CS0004: Introduction to Programming Relational Operators, Logical Operators, and If Statements.
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
2440: 211 Interactive Web Programming Expressions & Operators.
Chapter 3: Data Types and Operators JavaScript - Introductory.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
CPS120: Introduction to Computer Science Decision Making in Programs.
CSE 1301 Lecture 2 Data Types Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
Chapter 2: Using Data.
Logical Form and Logical Equivalence Lecture 2 Section 1.1 Fri, Jan 19, 2007.
20-753: Fundamentals of Web Programming 1 Lecture 12: Javascript I Fundamentals of Web Programming Lecture 12: Introduction to Javascript.
CMPS 1371 Introduction to Computing for Engineers CONDITIONAL STATEMENTS.
1 Boolean Expressions to Make Comparisons Boolean expression –Represents only one of two states –Expression evaluates to either true or false Expressions.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 2- 1 June 3, June 3, 2016June 3, 2016June 3, 2016 Azusa, CA.
6/3/2016 CSI Chapter 02 1 Introduction of Flow of Control There are times when you need to vary the way your program executes based on given input.
CONTENTS Processing structures and commands Control structures – Sequence Sequence – Selection Selection – Iteration Iteration Naming conventions – File.
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Introduction to branching.
Logical Form and Logical Equivalence Lecture 1 Section 1.1 Wed, Jan 12, 2005.
1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.
Sections © Copyright by Pearson Education, Inc. All Rights Reserved.
Introduction to Programming Lecture Note - 2 Visual Basic Programming Fundamentals.
CSCI 161 Lecture 7 Martin van Bommel. Control Statements Statements that affect the sequence of execution of other statements Normal is sequential May.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
COIT29222 Structured Programming 1 COIT29222-Structured Programming Lecture Week 02  Reading: Textbook(4 th Ed.), Chapter 2 Textbook (6 th Ed.), Chapters.
Programming with Microsoft Visual Basic th Edition
CIVIL AND GEOMATIC ENGINEERING FT Okyere. CIV 257- COMPUTER PROGRAMMING Lecture 3.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Fluency with Information Technology Third Edition by Lawrence Snyder Chapter.
CECS 5020 Computers in Education Visual Basic Variables and Constants.
Variables and Expressions Programming Right from the Start with Visual Basic.NET 1/e 7.
CS201 Introduction to Sabancı University 1 Chapter 2 Writing and Understanding C++ l Writing programs in any language requires understanding.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
CPS120: Introduction to Computer Science Decision Making in Programs.
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
An Introduction to Programming with C++ Sixth Edition Chapter 5 The Selection Structure.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
OPERATORS IN C CHAPTER 3. Expressions can be built up from literals, variables and operators. The operators define how the variables and literals in the.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
 Type Called bool  Bool has only two possible values: True and False.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. 4 Simple Flow of Control.
Data Types and Expressions
The Selection Structure
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Character Set Uppercase Alphabets A,
Chapter 8 JavaScript: Control Statements, Part 2
Chapter 2 Programming Basics.
Chapter 3: Selection Structures: Making Decisions
Boolean Expressions to Make Comparisons
The Data Element.
Chapter 3: Selection Structures: Making Decisions
The Data Element.
Using C++ Arithmetic Operators and Control Structures
Quick Test Professional Training Part 1
Presentation transcript:

VBScript Language

What is VBScript Based on the Visual Basic family of languages Supports object oriented features Interpreted Loosely Typed Implicitly Declared

Contents Syntax Rules Comments Naming Rules Data Types Storage –Variables, Constants, Arrays Operators –Arithmetic, Comparison, Logical, Assignment, Concatenation Branching –If –Select Looping –While –Do…While –For Sub/Functions –Built-In –User defined

Syntax Rules VBScript is not case sensitive –Except for strings (denoted by double-quotes) Each statement can only exist on one line –Unless you use a line continuation Statements can be either simple statements or compound statements

Comments Rem commented statement ‘ commented statement Can be a complete line or a portion of a line. VBScript does not support multi-line comments. The comment symbol must be put at the start of each comment.

Naming Rules 1.Must begin with a letter or the underscore Good: count, strInfo, _data Bad: 2day, 4get, *count violate this rule. 2.Cannot contain special characters except the underscore Good: Names using alphabets, numbers and the underscore. Bad: Names using symbols and other special characters. 3.Cannot match a reserved word Bad: for, if, Select 4.Must be unique within a context 5.Must be less than 256 characters

Naming Convention obj –Three letter prefix for the data type DescriptiveName –A descriptive name for the variable –First letter of each word in upper case objDescriptiveName

Literal Types Numeric –1 –3.14 –3E7 Boolean –True –False Characters –“Hello World” –“123 Straw Lane” –“43210” Date –#07/21/2006# –#Jan 6, 2008#

Variables Dim variableName Variables hold values that can change during program execution They function just like temporary storage locations Declaration of variables is optional, but recommended

Constants Const constantName = value Constant names hold values that cannot change during program execution Constants should be used in place of hard- coded values

Operations Operations are the many forms of computations, comparisons etc that can be performed in VB Most operations are binary in the form: operand1 operator operand2 Other operations are unary in the form operator operand1 When an operator has 2 symbols, you cannot separate them with a space: –Good: 2 <> 3 –Bad: 2 3

Arithmetic Used to perform calculations Both operands must be numeric values The result is a numeric value +Addition -Subtraction, Negation *Multiplication /Division \Integer Division ^Exponent ModModulo

Comparison Used to compare the value of two items Both operands must be of the same data type The result is a Boolean value =Equality <>Inequality <Less than >Greater than <=Less than or equals >=Greater than or equals

Logical Used to reduce Boolean values into a single Boolean value Both operands must be Boolean values The result is a Boolean value AndConjunction OrDisjunction NotNegation XorExclusion

And Truth Table Conjunction Used when both conditions are required Operand1Operand2Result TTT TFF FTF FFF

Or Truth Table Disjunction Used when either condition is sufficient Operand1Operand2Result TTT TFT FTT FFF

Not Truth Table Unary Operand Used to change the value of a condition Operand 1Result TF FT

Xor Truth Table Exclusion Used when either condition should be different Operand1Operand2Result TTF TFT FTT FFF

Assignment Changes the value of a variable = Uses the same symbol as an equality check operator. Assignment only occurs when used in any of the following forms: variable = literal value variable = expression variable = variable

Concatenation Combines 2 data types for display as a string &

Branching Allows you to avoid running certain sections of your code Code is only executed when a condition (or conditions) evaluate to True Provides a single application the ability to react differently to different input values

If If condition Then statement(s) End If Performs an operation only if the condition evaluates to True Used when an action is either performed or not performed.

If…Else If condition Then statement(s) Else statement(s) End If Performs the If portion only if the condition evaluates to True and the Else portion otherwise. Used in an either or scenario when an operation is always performed.

If…ElseIf If condition1 Then statement(s) ElseIf condition2 Then statement(s) Else statement(s) End If Only one section can be executed even if many conditions evaluate to True. Used in a multiple choice scenario Inclusion of the last Else is optional

Select Select Case variable statement(s) Case value1 statement(s) Case value2 statement(s) Case Else statement(s) End Select Used to choose between 1 of several discrete values for a variable. Inclusion of Case Else is optional Less powerful compared to the If statement

Loops Allows you to repeat running certain sections of your code Code executes when a condition (or conditions) evaluate to True Be careful with Loops. They can result in infinite processing. Forms –Entry Condition Entry only when a initial condition is met –Iterated Repeats for a specific number of times

Loops: Cautionary Items 1.Can this loop ever be entered If no, then you don’t need the loop 2.Can this loop ever be exited –If no, then you have an infinite loop

Loop: Parts 1.Where does the loop start? Expressed as an assignment 2.When does the loop end? Expressed as a condition 3.How is the loop variable altered? Expressed as an arithmetic operation Ensure that you are increasing/decreasing properly

While While condition statement(s) Wend Entry Condition Loop Simplest form of the loop Requires manual modification of the loop condition

For For variable = start To finish [Step change] statement(s) Next Iterated Loop Favored because all the loop details are in the definition statement

Function Function functionName(parameter list) statement(s) functionName = value End Function Block of code used to perform an operation Both VBScript and QTP provide a large number of built-in functions You can add your own built-in functions to the list

Best Practices Comment liberally Use a naming convention Avoid mixing cases Indent your code