Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Schongar P.VBScript unleashed.1997

.pdf
Скачиваний:
43
Добавлен:
23.08.2013
Размер:
1.59 Mб
Скачать

VBScript

UNLEASHED

Petroutsos, Schongar, et al.

CONTENTS

Chapter 1 Introducing HTML Scripting

Introduction

Designing Web Pages

Definitions

First Things First-HTML

The <HEAD> Tag

The <TITLE> Tag

The <BODY> Tag

Headings

Paragraphs

The <FONT> Tag

Links in Your Documents

Graphics

Multimedia in HTML

Tables

Forms in HTML

Using CGI Scripts in HTML

Other HTML Tags

Frames

Scripting

Objects

ActiveX Controls

Review

Chapter 2 The VBScript Language

Introduction

Differences Between Visual Basic and VBScript

Programming in VBScript

Creating a Test Page

What a Program Is

Concepts You Should Understand: Variables and Procedures

The Anatomy of VBScript Code

Data Types

Subtypes of Variant Types

Using Variables

Constants

Program Flow

Operators

Decision-Making in Programs

If...Then...Else

For...Next

Do...Loop

For Each...Next

While...Wend

Review

Chapter 3 VBScript Functions

Introduction

Procedures in Scripts

Sub Procedures and Function Procedures

Arguments to Procedures

Creating and Calling Functions

Intrinsic Functions

Basic Functions

InputBox

len

MsgBox

VarType

String Functions

Asc

Chr

InStr

LCase

Left

LTrim

Mid

Right

RTrim

Str()

StrComp

String

Trim

UCase

Val

Conversion Functions

CByte

CDbl

CInt

CLng

CStr

CVErr

Math Functions

Abs

Array

Atn

Exp

Hex

Int

Fix

Log

Oct

Rnd

Sgn

Sqr

Sin

Tan

Time and Date Functions

Date

DateSerial

DateValue

Day

Hour

Year

Weekday

Minute

Month

Now

Second

Time

TimeSerial

TimeValue

Boolean Functions

Review

Chapter 4 Intrinsic Controls

Introduction

Events in VBScript

Messages in a GUI Environment

Placing Controls in HTML

Intrinsic Controls

Button

Checkbox

Hidden

Text

Textarea

Select

Using Controls in Your Documents

Review

Chapter 5 VBScript in Web Pages

Using VBScript and HTML

Using the onLoad Event

Embedding VBScript in the HTML

Creating a New Page with VBScript

Using VBScript and CGI/ISAPI

Providing Database Access

Defining an ODBC Datasource

Creating the IDC Script File

Creating the Output Template File

Viewing the Results

Review

Chapter 6 The Scripting Model

Windows, Documents, and Frames

The window Object's Properties

Methods

The document Object

The document Object's Properties

The document Object's Methods

Using the document Properties and Methods

A Self-Modifying Document

Color Cycling

A Yearly Calendar

The history Object

The HistoryObject Project

The navigator Object

The BrowserInfo Project

The NavigatorObject Project

The location Object

The LocationObject Project

The link Object

The LinksObject Project

Review

Chapter 7 Using ActiveX Controls

Looking at a Brief History of Custom Controls

Examining the Anatomy of an ActiveX Control

Registering Your ActiveX Controls

Putting an ActiveX Control in Your Web Page

Installing and Distributing ActiveX Controls

Examining ActiveX Controls

Animated Button Control

Chart Control

Label

Popup Menu Control

Preloader Control

StockTicker Control

Timer Control

Using Third-Party Controls

Using Signed Controls

Creating ActiveX Controls

Using the Control Wizard to Create the Skeleton Files

Compiling a Control

Registering Your Control

Testing Your Control

Creating Non-MFC ActiveX Controls

Signing Your Objects for Internet Use

Review

Chapter 8 The ActiveX Control Pad

Taking a Tour of the ActiveX Control Pad

Text Editor

Object Editor

Page Editor

Script Wizard

Using ActiveX Controls

Creating VBScript with the Script Wizard

Using HTML Layouts

Looking at the Available Controls

Adding Controls to the Toolbox

Creating Interactive Content

Using VBScript with ActiveX Layouts

Review

Chapter 9 More ActiveX Controls

The Popup Menu and Menu Controls

The Popup Menu

The Menu Control

The Popup Window Control

The Marquee Control

The Chart Control

The Chart Example

Review

Chapter 10 Error Handling

Handling Errors in Your VBScript Pages

Syntax Errors

Errors with ActiveX Controls

Runtime Errors

Coding to Avoid Errors

Using the ActiveX Control Pad

Using Option Explicit

Using Coding Conventions

Coding to Handle Errors

Specifying Error Trapping

Using the Err Object

Looking at Examples of Error Handling

Trapping Runtime Errors

Using the Raise Method

Review

Chapter 11 Optimizing Code

Organizing Your Code

Chaos Theory 101

Code Behind the Scenes

Error Checking and Debugging

Use of Functions and Syntax

Variables Versus References

Data Types

ActiveX Controls

Quality, Not Quantity

Divide and Conquer

Development Tools

Still Using a Text Editor?

ActiveX Control Pad

Visual Basic to VBScript Converters

Future Integrated Development Environments?

Review

Chapter 12 Debugging

Handling VBScript Errors

Syntax Errors: Say What You Mean!

Semantic Errors: Mean What You Say!

Using Simple Debugging Techniques

Using the MsgBox Statement

Using the On Error Resume Next Statement

Using the Err Object

Taking the Err Object Further

Using Advanced Debugging Techniques

Tracing Your Code Using the Message Box

Saturating Your Code with the Message Box

Watching Your Code Using Variables and the Message Box

Breaking Apart Complex Statements to Find Bugs

Using Other Tools to Help You with the Debugging Task

Using VBScript Versus Traditional Debugging Environments

Using Visual Basic to Debug VBScript Applications

Using Visual Basic 4.0 Trace Capabilities

Debugging VBScript Code Within Visual Basic

Handling HTML Errors

Making Sure the Bugs Are Dead

Creating Your Own Debug Window for Tracing

Building Your Own Tracing Routines

Looking at a Sample Variable Analysis Routine

Looking at More Reasons Why VBScript Can Be Tough to Debug

The Moral of the Story

Review

Chapter 13 Dynamic Web Page Building

Using the Internet Explorer Document Object

Properties and Collections

Methods

Using the ActiveX Timer Control

Writing the Current Date and Time to the Page

Creating a Random Frame Using Client-Side Refresh

Changing the Document's Colors

Using Cookies to Maintain User Information

Review

Chapter 14 Customize Your Web Page with Cookies

Safety Considerations

What Are Cookies?

Creating Cookies

How to Test Pages with Cookies

The Cookie Folder

Extracting the Cookie Values

Review

Chapter 15 Creating Active Documents for Corporate Intranets

Client-Side Processing

Distributed Applications

Databases

Functionality and Flexibility

Native Document Hosting

Component Architecture

Third-Party Innovation

Return on Investment (ROI)

Maintenance

Expansibility and Integration

Standards

Investment Protection

Employee Efficiency

Company Image

Review

Chapter 16 Controlling MS Office Documents in Web Pages

ActiveX

ActiveX Scripting

ActiveX Control Pad

Leveraging Your Investment

Microsoft Office Suite

Relevant Web Sites

Review

Chapter 17 Animation

ActiveX Controls Capable of Animation

Frame Animation with Image and Timer Controls

Rotating Text with the Label Control

Using Active Movie for Digital Audio and Video

The Marquee Control for Scrolling Pages

Other HTML Tags that Provide Multimedia Playback

Chapter 18 VBScript and Java

What Is Java?

Java, Java Applets, and JavaScript

Java Classes

JavaScript Objects

JavaScript Language Structure

JavaScript Operators

JavaScript Flow of Control Statements

VBScript Language Structure

VBScript Examples

VBScript Variables

VBScript Operators

VBScript Err Object

VBScript Variant Data Type

VBScript Constants

VBScript Flow of Control Statements

VBScript Functions

VBScript Procedures

ActiveX

Standards and Conventions

Comparing Java, JavaScript, and VBScript: A Summary

Examples

Relevant Web Sites

Review

Chapter 19 VBScript and DLLs

Static Versus Dynamic Library

Structure of a DLL

The Entry Function

The LibMain Function

The Exit Function

Programmer-Defined Functions

Exported Functions

Non-Exported (Internal) Functions

Why Use DLLs?

Disadvantages of Using DLLs

A Sample DLL

VBScript and DLLs

Relevant Web Sites

Review

Chapter 20 CGI and VBScript

Understanding CGI

CGI Specification

CGI Environment Variables

Architecture of a CGI Application

CGI Versus VBScript

Examples

Relevant Web Sites

Review

Chapter 21 Safety and Security

A Matter of Trust…

Can VBScript Security Hold Up?

VBScript's Built-In Safeguards

Flirting with Danger-ActiveX Components

Authentic Controls-Friend or Foe?

Rogue Controls

Defending Against Friendly Fire and Nasties

Paranoia, Self-Defense, and Reasonable Risk

Chapter 22 VBScript as a Component in Other Applications

Porting VBScript to VBA and Visual Basic

All About ActiveX Scripting

Script Engines

Script Hosts

Communications Between Scripting Engines and Hosts

Licensing

The Binary Route

Source Code

Putting It All Together-Microsoft's "Spruuids" Example

Future Hosts

Chapter 23 Conversions and Calculations

Metric Conversions

The User Interface

The TabStrip Control

Implementing the Conversions Utility

Programming the Application

A Financial Calculator

The User Interface

A Math Calculator

The User Interface

Programming the Application

Improving the Calculator

Further Improvements

Review

Chapter 24 WWW Personal Information Manager

Overview

How It Works

Creating the Page

Working with Cookies

Creating Dynamic HTML

Presenting Information

Tying It All Together

Review

Chapter 25 Order Entry

Ensuring Secure Transactions on the Web

Authenticating the Merchant

Authenticating the Purchaser

Encrypting Web Communications

Reviewing Cookies

Designing the Order Entry Form

Creating the Order Entry Form

Examining the VBScript Code

Testing the Application

Review

Chapter 26 RTFEditor

Using OCX Controls with VBScript

The RTFEditor Application

The Rich Textbox Control

Designing the User Interface

The Code Behind the Scenes