- Mental Model: Where Everything Goes
- Review: Guest Book Database and Form
- General Properties of Active Server Pages Scripts
- The Insert Script, Part 1: insert.asp
- The Insert Script, Part 2: Basic Error Handling
- The Insert Script, Part 3: Redirection
- The Retrieve Script
General Properties of Active Server Pages Scripts
Active Server Pages scripts can contain both HTML commands and Visual Basic commands. Similar to how HTML commands are contained within a beginning symbol (<) and ending symbol (>), Visual Basic commands are enclosed between special beginning and ending symbols. The beginning symbol is the less-than character followed by a percent sign (<%), and the ending symbol is the percent sign followed by the greater-than character (%>). For brevity's sake, we'll call the former "begin-percent" and the latter "end-percent." The Visual Basic commands you put between the begin-percent and end-percent are a subset of Microsoft's full-blown Visual Basic language, known as Visual Basic Script, or VBScript for short. For example, here's a small snippet of VBScript for calculating an area, given a width and a height:
<% width = 7 %> <% height = 3 %> <% area = width * height %>
You can save typing by placing all the lines between one pair of begin-percent and end-percent signs, instead of giving each statement its own set. Here's the same snippet as just shown, using a single set of begin-percent and end-percent symbols:
<% width = 7 height = 3 area = width*height %>
Notice that we've collapsed the spaces around the asterisk (*) while we were cleaning up.
That doesn't look too daunting, does it? You just need to get used to the syntax and the language. There's no better teacher than experience, so let's dive into the details of the insert script.