| 9.0 |
Adding
and Modifying VBScript.
Now we need to add some code to our page and modify the code
that Ultradev has generated for us in order to get our Results
page to return the results according to the criteria specified
on the Search page.
Click on the code view button
at the top left of the Page Design window to see the results
page in code view.
Initially we are going to be concentrating on the section above
the HTML. Scroll down the page in code view until you find the
following: <html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000"...
Everything above this is the script, either VBScript
or JavaScript. In this instance we have not used any JavaScript
functions so there isn't any JavaScript.
The VBScript we can see before the HTML is run at the Server
(Server Side) and in effect compiles the page before it is sent
to the Browser (Client Side) as pure HTML. You may have noticed
when you are viewing an ASP page in your browser and you right
click and select View Source you can't see any of the code.
It is beyond the scope of this tutorial to provide a complete
understanding of VBScript, however in an attempt to explain
how the code works the code in the completed results page originalresults.asp
has been extensively commented. In addition you can view The
Results Page Code, in which I have outlined the code added
and the modifications to the Ultradev generated code.
In addition you can download the VBScript documentation from
Microsoft
http://msdn.microsoft.com/scripting/vbscript/download/vbsdoc.exe
You can also find lots more useful Scripting information
at: http://msdn.microsoft.com/scripting/default.htm
NOTE
Once you have added the code to the page and modified
some of the Ultradev generated code you will notice that when
you return to the page view that the Data Bindings window and
The Server Behaviours window no longer function properly. Because
we have modified the code so extensively Ultradev can no longer
properly identify it's behaviours. This will not affect the
final function of the page. This is why we added the behaviours
that enable us to show, hide and repeat regions of the page
prior to modifying the code.
In addition you will notice that some values in the originalsearch.asp
page code, such as the links and the Query names are different
so that they will still function while you are building your
own versions of the pages. Some
very, very basic VBScript notes.
Variable - A variable is virtual container in the computers
memory that can be used to hold information. VBScript has some
built in variables for special puposes and you can also create
your own variables. Variables can then be used to hold anything
from a single digit number or a text String. In addition a Variable
can be empty.
String - A String is technically speaking a variant subtype,
but basically it's a collection of characters either numerical
or alphabetical or a mixture of both. Strings can be of any
length from 0 to approximately 2 billion characters. (American
billion = 1,000,000,000).
Some VBScript syntax. |
| |
Symbol |
Type |
Description |
| |
+ (addition) |
Operator |
Adds two umbers together.
You can also use this to concatenate strings. |
| |
' (comment Indicator) |
Keyword |
Used within code to add comments.
Any text after the ' symbol is notexecuted. |
| |
" (double quotes) |
Keyword |
Shows the start and end of
a literal string. |
| |
& (string concatenation)
|
Operator |
Performs the concatenation
of string expressions. |
| |
/ (division, floating point)
|
Operator |
Divides two numbers and returns
a floating point reult. |
| |
\ (division, integer) |
Operator |
Divides two numbers and returns
an integer result. |
| |
= (equals) |
Comparison |
Checks whether two expressions
are equivalent. |
| |
^ (exponent) |
Comparison |
Raises a umber to the power
of anexponent. |
| |
>= (greater than or equal
to) |
Comparison |
Checks whether the left sideexpression
is greater than or equalto the right side expression. |
| |
< (less than) |
Comparison |
Checks whether the left sideexpression
is less than or equal to theright side expression. |
| |
<= (less than or equal
to) |
Comparison |
Checks whether the left sideexpression
is less than or equal to theright side expression. |
| |
_ (line continuation) |
Keyword |
Indicates that the current
line continues onto the next line. |
| |
* (multiplication) |
Operator |
Multiplies two numbers. |
| |
- (subtraction or indicator) |
Operator |
Finds the difference between
twonumbers or when applied to anoperand treats it as a negative
number |
| |
<> (not equal) |
Comparison |
Checks whether two expressions
arenot equivalent. |