1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a...
-
Upload
deborah-underwood -
Category
Documents
-
view
218 -
download
0
Transcript of 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a...
![Page 1: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/1.jpg)
1
Scripting Languages
• VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in
• JavaScript - Recognized by Internet Explorer and Netscape
• Perl - Used at the server side• Server v.s. Client programming• VBScript is similar to VB programming, but uses
a subset of the language.
![Page 2: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/2.jpg)
2
VBScripting
• To include a control use input tags.– <INPUT TYPE=BUTTON NAME=cmdButton
VALUE="Click Here">
• To have VBScript recognized by the browser - use the following:– <SCRIPT LANGUAGE="VBScript">– <!-- Use comment tag so that browsers that do not
support VBScript will not print the code -->– </SCRIPT>
![Page 3: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/3.jpg)
3
VBScripting contd.
• To build the command button for the Input tag:– <SCRIPT LANGUAGE="VBScript">– <!-- – Sub cmdButton_OnClick
• Msgbox ”Please enter a number from 1 to 10."
– End Sub
![Page 4: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/4.jpg)
4
Data - Variables & Constants
• Constant is data that will not change - fixed in value
• Variable is data that can change during the course of the running of a program
• Identifier is a name assigned to a variable or constant - memory is reserved for the variable / constant
• Declaration statements define the variable / constant for the program
![Page 5: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/5.jpg)
5
Declaration Statements
• Const Identifier [As Datatype] = Value• Const is a reserved word to define a constant in
the declaration section• Dim Identifier [As Datatype]• A defaulted datatype becomes type variant• String values are called string literals• Intrinsic constants are VB built-in constants
![Page 6: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/6.jpg)
6
Data Types
• Boolean - True or False value (0 or 1)• Byte - A single ASCII character• Single & Currency - Floating Point • Date - An eight character date• Double - Double precision floating point • Long & Integer - Whole number• String - Alphanumeric characters• Variant - Stores any type
![Page 7: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/7.jpg)
7
Local Declarations
• The Dim statement can be placed anywhere within the local procedure
• It is recommended to be placed at the top of the procedure
• It must be placed before the variable is used• Variables and constants can be declared locally
![Page 8: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/8.jpg)
8
Arithmetic Operators
• The order of precedence is as follows:– Exponentiation - [^]– Multiplication and Division - [*, /]– Addition and Subtraction - [+, -]
• Use parenthesis to change evaluation order of a mathematical expression
• All evaluations occur from left to right• Parenthesis are performed first then in the order
of precedence
![Page 9: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/9.jpg)
9
Arrays
• A series of items (Data Types) that are related to one another
• They use the same name with an index to each part (element) of the array
• They are similar to a control array except they are for data storage
• The name tables or subscripted variables is sometimes used with them
• The index is the subscript of the array
![Page 10: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/10.jpg)
10
Dimensioning Arrays
• The Dim statement is used similar to all other declarations
• Dim Arrayname ([lower To] Upper) [As Datatype]
• The lower subscript is not necessary - if left out the lower subscript will be zero
• The datatype may be left out and defaults to variant
• All data elements are initialized to zero for numerics and null string for strings
![Page 11: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/11.jpg)
11
Dynamic Arrays
• Arrays can be dimensioned dynamically• An array declared as - Dim Name() As Integer• Will allow redimensioning during program
execution• The Redim statement is used to rediminsion an
array• All other arrays are static arrays
![Page 12: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/12.jpg)
12
Array Subscripts
• The subscript used to reference into the array can be a constant
• A literal number• A variable• A numeric expression• The subscript MUST reference a valid element
of the array
![Page 13: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/13.jpg)
13
Message Boxes
• Message Boxes are used to notify the user of an error or display information
• The message box can contain a message, icon, title bar caption or command button
• MsgBox “message” [,buttons/icon][, “title bar”] • Displays the message centered in box• Displays title bar caption in the title bar
![Page 14: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/14.jpg)
14
Message Box Buttons
• vbOKOnly - 0 - Shows only the OK button
• vbOkCancel - 1 - Shows the OK and Cancel buttons
• vbAbortRetryIgnore - 2 - Shows the Abort, Retry and Ignore buttons
• vbYesNoCancel - 3 - Shows the Yes, No and Cancel buttons
• vbYesNo - 4 - Shows the Yes and No buttons
• vbRertyCancel - 5 - Shows the Retry and Cancel buttons
![Page 15: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/15.jpg)
15
Message Box Parameters
• vbCritical - 16 - Uses a Critical X as an indicator
• vbQuestion - 32 - Uses a Question mark as an indicator
• vbExclamation - 48 - Uses a Exclamation point as an indicator
• vbInformation - 64 - Uses an I as an indicator
![Page 16: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/16.jpg)
16
Message Box Return Codes
• vbOk -1 - Indicates an OK status
• vbCancel - 2 - Indicates a return of cancel
• vbAbort - 3 - Indicates a return of abort
• vbRetry - 4 - Indicates a return of retry
• vbIgnore - 5 - Indicates a return of Ignore
• vbYes - 6 - Indicates a return of yes
• vbNo - 7 - Indicates a return of No
![Page 17: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/17.jpg)
17
Procedures / Functions
• A sub procedure is code that performs a given operation, but does not return anything.
• A function is code that performs a given operation and then returns a value to the caller. This value can be the result of some operation or just an error code.
• The returned value is accomplished by using the name of the function and assigning a value.
• To exit a sub procedure prematurely use Exit Sub.
![Page 18: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/18.jpg)
18
Functions
• Functions perform an action and return a value associated with that action
• The VAL function will convert data into a numeric format
• The Val function converts until the first non-numeric character is read
![Page 19: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/19.jpg)
19
System Procedures
• There are two types of system classes.– Events - a subroutine executed automatically by the
system when a certain event takes place.• OnBlur - executed when an object is deselected
• OnChange - executed when a user changes the object
• OnClick - executed when an object is clicked
• OnFocus - executed when an object is active (user selects)
– Methods - controlled events. Methods normally are used to cause something to occur.
• Calling a method is done by using the object name and the method name.
• Objectname.Methodname
![Page 20: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/20.jpg)
20
Conditional Statements
• If ( condition) Then– statements
• ElseIf (condition) Then– statements
• Else– statements
• End If• All data types must be of the same type
![Page 21: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/21.jpg)
21
Relational Operators
• The relational operators are used to compare two values - the result of the comparison is either True or False
• > - Greater than• < - Less than• = - Equal to• <> - not equal to• >= - Greater than or equal to• <= - Less than or equal to
![Page 22: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/22.jpg)
22
Conditional Statements contd.
• ASCII comparisons, handled left to right • All string literals must be enclosed in double
quotes• Be careful using text boxes - their data type is
variant• To check uppercase characters - Ucase()• To check lowercase characters - Lcase()• Use logical operators to test multiple conditions -
Or , And , Not, Xor, Equ, Imp
![Page 23: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/23.jpg)
23
Conditional statements contd.
• Nested If Statements can be used, just remember to include the End If inside the nested If
• The nesting can be accomplished in the Then portion of the condition, or in the Else portion
• The ElseIf statement or an If within an If are both valid statements
• It is highly recommended to flowchart conditional statements
![Page 24: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/24.jpg)
24
Case Statements
• Multiple If tests (nested or otherwise) can be replaced with the Case Statement
• It is easier to read and easier to construct
![Page 25: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/25.jpg)
25
Case Statement contd.
• Select Case expression– Case Is relational expression
• Statement
– Case Constant To Constant• Statement
– [Case Else]• Statement
• End Select
![Page 26: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/26.jpg)
26
Do Loops
• Do Loops repeat instructions until a condition is met
• Do While condition– statements to be repeated
• Loop• Do
– statements to be repeated• Loop Until condition
![Page 27: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/27.jpg)
27
For / Next Loops
• Used to allow repetitive operations in a sequence of code.
• For LoopIndex = Startvalue To EndValue [Step Increment]– statements to be repeated
• Next LoopIndex
• The Loop Index must be declared before entering the loop and the end value must be attainable.
![Page 28: 1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.](https://reader035.fdocuments.in/reader035/viewer/2022062518/5697bf941a28abf838c8febf/html5/thumbnails/28.jpg)
28
For / Next Loops contd.
• Once the end value has been reached the execution will drop out of the loop.
• Negative numbers are allowed for the step value
• Altering the values of the control variables will not affect the operation of the loop