《软件技术专业外文翻译》由会员分享,可在线阅读,更多相关《软件技术专业外文翻译(12页珍藏版)》请在金锄头文库上搜索。
1、英文资料翻译ASP Language BasicsActive Server Pages (ASP) is a proven, well-established technology for building dynamic Web applications, which provides the power and flexibility you need to create anything from a personal, Web based photo gallery to a complete catalogue and shopping cart system for your n
2、ext eCommerce project. One unique feature of ASP is that it lets you choose your favourite scripting language, be it JavaScript or VBScript; however, VBScript is by far the most popular choice. In this article, Ill bring you up to speed on the basic syntax of the VBScript language, including variabl
3、es, operators, and control structures.This article is the second in a series teaching ASP. Specifically, the goal of this series is to teach you all you need to know to create dynamic Web sites using ASP. This article picks up right where the previous article in the series, Getting Started with ASP,
4、 left off.VariablesHere is the listing for the first ASP script I helped you create in the previous article:1 2 3 My First ASP Page 4 5 6 % 7 Write out a simple HTML paragraph 8 Response.Write This is a test of ASP. 9 % 10 11 As I admitted in that article, this is a pretty uninteresting example of a
5、n ASP script. When it comes right down to it, this script doesnt do anything a plain, old HTML page couldnt do. Oh sure, I gave a slightly more interesting example that displayed the current server time, but to be really useful a script needs to perform some form of calculation, or manipulate dynami
6、c information to present it in some interesting way. The language used for writing most ASP programs, and which Ill be using throughout this series, is called VBScript. Like most programming languages, VBScript lets you store data in variables. A variable may be thought of simply as a named location
7、 in memory where data may be stored. VBScript is what is known as a loosely typed language, which means that a particular variable may store any kind of information, be it a number, a piece of text, a date, or some more complicated chunk of data (as opposed to strictly typed languages where you can
8、only store one kind of information in each variable). Before you can use a variable, though, you must declare it; that is, you must let ASP know that you want to create a variable with a particular name.Lets look at a basic example to help solidify these concepts in your mind. Say you were writing a
9、 Web page that performed conversions between Celsius and Fahrenheit temperatures. In countries where Celsius is used, 20°C is commonly accepted as the value for room temperature. The following code creates a variable called intRoomTempC, and then assigns it a value of 20:New Revised 2nd Edition
10、Out NOW!Build Your Own Database Driven Website Using PHP & MySQL Fully updated for PHP 4.3.Installation instructions for Mac OS XFull index providedNew wider book sizeEnhanced fontsNew cover designLay-flat spineAll content revisitedDownload the First 4 Chapters FREETell me more about this top-sellin
11、g book.Dim intRoomTempC Create a variable intRoomTempC = 20 Assign the variable a value of 20The keyword Dim in the above is short for dimension, and is used to tell VBScript to create a variable with the name specified (in this case, intRoomTempC). Why dimension, you ask? I agree, its not the most
12、obvious choice, but basically it refers to what youre asking VBScript to do. When creating a variable, VBScript needs to assign some space in memory to store whatever value(s) will be placed in the variable, and part of that task is to figure out the size (dimension) of the space that needs to be al
13、located. In any case, creating a variable is as simple as typing Dim followed by the name of the variable.The second line of the above example assigns a value to the variable that was just created; specifically, it stores the number 20 in the variable. The equals sign (=) is called the assignment op
14、erator because it is used to assign values to variables. During the course of this article, youll meet many other operators that do other weird and wonderful things to variables and the values they store.You should always create a variable before assigning it a value, and youll usually want to assig
15、n the variable a value before putting it to use. Trying to assign a value to a variable that does not exist, however, will cause VBScript to automatically create a new variable with the given name. This is called implicit declaration, because a new variable is declared implicitly as a result of your
16、 trying to assign a value to a variable that doesnt exist. Since you are free to use implicit declaration for all of your variables, you may be wondering what the point is of using the Dim command to create each and every variable by hand.The answer has to do with how easy you want it to be to find typing mistakes