2. Compiled LanguagesCompiled Languages
Source File (Text)Source File (Text)
Pre-process – Replace/update directivesPre-process – Replace/update directives
Compile – Create assembly language fileCompile – Create assembly language file
Compilers and machine specificCompilers and machine specific
Once compiled, cannot be decompiled (easily) – Not 1-to-1Once compiled, cannot be decompiled (easily) – Not 1-to-1
Assemble – Create binary executableAssemble – Create binary executable
AdvantagesAdvantages
Fast!Fast!
(Relatively) Safe from alteration/theft(Relatively) Safe from alteration/theft
Use traditional languages (smaller learning curve, lots ofUse traditional languages (smaller learning curve, lots of
talent available)talent available)
DisadvantagesDisadvantages
Not portableNot portable
Need to re-compile to changeNeed to re-compile to change
Not efficient for simple tasksNot efficient for simple tasks
3. Scripting Languages BackgroundScripting Languages Background
Unix Shell scripts – sh, csh, bash, tcsh, zsh,Unix Shell scripts – sh, csh, bash, tcsh, zsh,
kshksh
Allowed easier performance of basic system tasksAllowed easier performance of basic system tasks
Text commands could be “processed”Text commands could be “processed”
Same concept as batch filesSame concept as batch files
Standalone scripting languagesStandalone scripting languages
Awk, sed, grep, etc…Awk, sed, grep, etc…
Allowed limited power to do repetitive tasks easyAllowed limited power to do repetitive tasks easy
Made for specific-purposeMade for specific-purpose
4. Scripting Languages - GeneralScripting Languages - General
TCL/TKTCL/TK
PythonPython
PERLPERL
Used for more advanced programming tasksUsed for more advanced programming tasks
Became almost as powerful as any compiled languageBecame almost as powerful as any compiled language
AdvantagesAdvantages
Text files – can be ported anywhere!Text files – can be ported anywhere!
Easy to changeEasy to change
Easy to write/debugEasy to write/debug
DisadvantagesDisadvantages
Slow – must be interpreted by a script interpreter (not standalone)Slow – must be interpreted by a script interpreter (not standalone)
Not quite as powerful as compiled languages (e.g. for addressing ofNot quite as powerful as compiled languages (e.g. for addressing of
hardware)hardware)
5. Scripting Languages – Web BasedScripting Languages – Web Based
Originally PERL was most popular through CGIOriginally PERL was most popular through CGI
PERL had issuesPERL had issues
SlowSlow
Required a new instance of the PERL interpreter toRequired a new instance of the PERL interpreter to
spawn with each requestspawn with each request
Somewhat convoluted to learn – based on C/C+Somewhat convoluted to learn – based on C/C+
+/Unix scripting+/Unix scripting
Interpreter support was scatteredInterpreter support was scattered
Not built specifically for the webNot built specifically for the web
Only Server SideOnly Server Side
PERLEXAMPLE1PERLEXAMPLE1
6. Web Scripting – JavaScript HistoryWeb Scripting – JavaScript History
~1994 Netscape begins building LiveScript!~1994 Netscape begins building LiveScript!
Netscape forms alliance with Sun, gains naming rights toNetscape forms alliance with Sun, gains naming rights to
Java nameJava name
Renames LiveScript Javascript, and releases withRenames LiveScript Javascript, and releases with
browser 2.0browser 2.0
Microsoft responds with VBScriptMicrosoft responds with VBScript
Microsoft response with JscriptMicrosoft response with Jscript
Netscape fires back with 1.1, 1.2 versionsNetscape fires back with 1.1, 1.2 versions
ECMA – European Computer Manufacturers AssociationECMA – European Computer Manufacturers Association
– creates non-partisan standard– creates non-partisan standard
Javascript designed for client-side scriptingJavascript designed for client-side scripting
Netscape had >50% of the marketNetscape had >50% of the market
JSEXAMPLE1JSEXAMPLE1
7. Web Scripting – VBScript HistoryWeb Scripting – VBScript History
Visual BasicVisual Basic
Created as a simple alternative to C/C++ developmentCreated as a simple alternative to C/C++ development
Supported RAD within WindowsSupported RAD within Windows
Based on BASIC programming languageBased on BASIC programming language
Contained and IDE, support for GUI tools for displayContained and IDE, support for GUI tools for display
Became overnight successBecame overnight success
Visual Basic for ApplicationsVisual Basic for Applications
Subset of Visual BasicSubset of Visual Basic
Created to extend other programs (e.g. Office)Created to extend other programs (e.g. Office)
Used standard VB commandsUsed standard VB commands
Adopted by other companies to customize their applicationsAdopted by other companies to customize their applications
(Siebel, Clarify)(Siebel, Clarify)
8. Web Scripting – VBScript History,Web Scripting – VBScript History,
cont’dcont’d
Visual Basic Scripting EditionVisual Basic Scripting Edition
Created as a “safer” version of VBACreated as a “safer” version of VBA
Strict subset of VBAStrict subset of VBA
Made in response to JavascriptMade in response to Javascript
Supported in Internet Explorer 3.x+Supported in Internet Explorer 3.x+
Easier to learn, based on familiar VB/BASICEasier to learn, based on familiar VB/BASIC
commandscommands
Originally client sideOriginally client side
No file reads/writes/OS manipulation like VBANo file reads/writes/OS manipulation like VBA
Expanded to Server sideExpanded to Server side
Expanded to OutlookExpanded to Outlook
Problem .vbs extensions!Problem .vbs extensions!
9. Web Scripting – VBScript History,Web Scripting – VBScript History,
cont’dcont’d
Expanded to support ASP pages (serverExpanded to support ASP pages (server
side!)side!)
Allowed dynamic SQL queriesAllowed dynamic SQL queries
Allowed better SSIAllowed better SSI
Could actually do real-time calculationsCould actually do real-time calculations
Removed the limitations of PERLRemoved the limitations of PERL
Still a bit slow, interpreted, and not quite asStill a bit slow, interpreted, and not quite as
robust as VBrobust as VB
10. VBScript BasicsVBScript Basics
<script> tag<script> tag
delineates scripting language code will followdelineates scripting language code will follow
AttributesAttributes
type=“text/vbscript”type=“text/vbscript”
language=”vbscript” or “vbs”language=”vbscript” or “vbs”
runat = “server” (default is browser)runat = “server” (default is browser)
VBScript is Case insensitiveVBScript is Case insensitive
Whitespace is ignoredWhitespace is ignored
Comments should use ‘ or RemComments should use ‘ or Rem
Code is denoted by lines. To span multiple lines, use _Code is denoted by lines. To span multiple lines, use _
Code outside of a subroutine or function automaticallyCode outside of a subroutine or function automatically
runs on page loadruns on page load
VBEXAMPLE1VBEXAMPLE1
11. VBScript Basics – Data TypesVBScript Basics – Data Types
Only one main type – VariantOnly one main type – Variant
Similar to variable in other languagesSimilar to variable in other languages
No specific datatype (e.g. integer, real,No specific datatype (e.g. integer, real,
character, string, etc…)character, string, etc…)
Global or local scopeGlobal or local scope
Declared using the Dim statementDeclared using the Dim statement
Dim var1, var2, var3Dim var1, var2, var3
var = 0var = 0
var = “Hello World”var = “Hello World”
12. VBScript Basics – Data SubtypesVBScript Basics – Data Subtypes
Controlled by VBScript engineControlled by VBScript engine
0 -Empty – Declared, but no value is assigned0 -Empty – Declared, but no value is assigned
1 -Null – Contains no valid data1 -Null – Contains no valid data
Var = NULLVar = NULL
11 - Boolean11 - Boolean
Var1 = TrueVar1 = True
17 - Byte – 0 – 25517 - Byte – 0 – 255
2 - Integer - -32,768 – 327672 - Integer - -32,768 – 32767
3 - Long - -2,000,000,000 – 2,000,000,0003 - Long - -2,000,000,000 – 2,000,000,000
4,5 - Single, Double – Real numbers (decimals!)4,5 - Single, Double – Real numbers (decimals!)
7 - Date/Time – 01/01/100 – 12/31/99997 - Date/Time – 01/01/100 – 12/31/9999
6 - Currency6 - Currency
8 - String8 - String
9 - Object – HTML or ActiveX9 - Object – HTML or ActiveX
10 - Error10 - Error
13. VBScript Basics – VariableVBScript Basics – Variable
OperationsOperations
Determining the variable subtypeDetermining the variable subtype
VarType (var1)VarType (var1)
Returns numeric representation of the datatypeReturns numeric representation of the datatype
TypeName (var1)TypeName (var1)
Returns actual name of type!Returns actual name of type!
VBScript can perform operations on two variants without needingVBScript can perform operations on two variants without needing
you to make the types agreeyou to make the types agree
Var1 = 7Var1 = 7
Var2 = 123.23Var2 = 123.23
Var3 = Var1 + Var2Var3 = Var1 + Var2
ConstantsConstants
Const PI 3.14Const PI 3.14
Usually capitalizedUsually capitalized
Cannot be changedCannot be changed
VBEXAMPLE2VBEXAMPLE2
14. VBScript Basics – Math OperatorsVBScript Basics – Math Operators
+ addition+ addition
var1 = var2 + var3var1 = var2 + var3
–– subtractionsubtraction
var1 = var2 – var3var1 = var2 – var3
/ division/ division
var1 = var2 / var3var1 = var2 / var3
* multiplication* multiplication
var1 = var2 * var3var1 = var2 * var3
Integer division Integer division
var1 = var2 var3var1 = var2 var3
Returns only the integer portionReturns only the integer portion
Mod – moduloMod – modulo
Var1 = var2 Mod var3Var1 = var2 Mod var3
Returns the remainder after divisionReturns the remainder after division
^ - Exponentiation^ - Exponentiation
var1 = var2 ^ var3var1 = var2 ^ var3
15. VBScript Basics – LogicalVBScript Basics – Logical
OperatorsOperators
Concatenation - &Concatenation - &
““Adds” strings togetherAdds” strings together
ComparisonComparison
>, <, <>, >=, <=, =>, <, <>, >=, <=, =
Returns a “True” or a “False”Returns a “True” or a “False”
E.g. var1 > 6E.g. var1 > 6
LogicalLogical
AND, Or, NotAND, Or, Not
VBEXAMPLE3VBEXAMPLE3
16. VBScript Basics – ControlVBScript Basics – Control
Statements – If-Then-ElseStatements – If-Then-Else
Determine program flowDetermine program flow
Conditional statementsConditional statements
If – ThenIf – Then
If var1 > 2 ThenIf var1 > 2 Then
Document.Write “var1 >2”Document.Write “var1 >2”
End IfEnd If
If – Then – ElseIf – Then – Else
If var1 > 2 ThenIf var1 > 2 Then
Document.Write “var1 >2”Document.Write “var1 >2”
ElseElse
Document.Write “var1 <=2”Document.Write “var1 <=2”
End IfEnd If
17. VBScript Basics – ControlVBScript Basics – Control
Statements – If-Then-ElseIfStatements – If-Then-ElseIf
If – Then – ElseIfIf – Then – ElseIf
Same as nested If’sSame as nested If’s
If var1 > 2 ThenIf var1 > 2 Then
Document.Write “var1 >2”Document.Write “var1 >2”
ElseIf var1 = 2 ThenElseIf var1 = 2 Then
Document.Write “var1 = 2”Document.Write “var1 = 2”
ElseElse
Document.Write “var1 < 2”Document.Write “var1 < 2”
End IfEnd If
VBEXAMPLE4VBEXAMPLE4
18. VBScript Basics – ControlVBScript Basics – Control
Statements – Select-CaseStatements – Select-Case
Concise way of writing multiple if-then statementsConcise way of writing multiple if-then statements
Select Case nameSelect Case name
Case “Bob”Case “Bob”
Document.Write “Bob”Document.Write “Bob”
Case “Mary”Case “Mary”
Document.Write “Mary”Document.Write “Mary”
Case “Bill”Case “Bill”
Document.Write “Bill”Document.Write “Bill”
Case ElseCase Else
Document.Write “Other case!”Document.Write “Other case!”
End SelectEnd Select
VBEXAMPLE5VBEXAMPLE5
19. VBScript Basics – LoopingVBScript Basics – Looping
Repeats a command or set of commandsRepeats a command or set of commands
For – NextFor – Next
For x = 1 to 20For x = 1 to 20
Document.Write “<br />” & xDocument.Write “<br />” & x
NextNext
VBEXAMPLE6VBEXAMPLE6