ASP 3.0 Advanced Programming (VII)

Source: Internet
Author: User
Tags date array empty variables parent directory string variable tostring
Programming | Advanced (4) Deleting a virtual application
Clicking the Remove button does not really delete the entry in Internet Services Manager. Instead, you convert an existing virtual application to a virtual directory. This directory has a "folder" icon with a blue ball, which means that this is not a real directory in the Web site, but a redirect to another folder on the disk. It is accessed in the same way as the virtual application that created it (that is, using the same URL), but not as an application. In other words, it does not support its own application object, but rather inherits the application object of the default Web site or the Application object of another application in the parent directory of that directory.
To remove a virtual application, simply right-click the object in Internet Services Manager and select Delete from the menu that pops up.
(5) What the application stores
The global storage space provided by the ASP Application object can be used to store the following:
· Simple variables, such as strings and numbers (stored as variants, similar to ASP script variables).
· Variant type array, one-dimensional or multidimensional.
· A variable reference to a COM object instance (of type in a variant).
(6) Definition of variant
A variant is a unique variable type that is provided for ASP (and Internet Explorer) in the VBScript scripting engine, similar to the variant of the data type defined in VB and VBA. Compared to most commonly used basic data types, such as strings or integers, the variant provides many uses, although it does not allow the storage unit to store variables most efficiently and requires additional processing.
From within the Variant data type stores numeric values as separate subtypes. It handles implicitly type conversions automatically, allowing the following code to be used:
strstring = "30"
Intinteger = 12
Response.Write strstring & Intinteger ' writes 3012 in the resulting page
Response.Write strstring + Intinteger ' writes in the resulting page
Implicit data type conversions allow you to ignore HTML values in Guangxi and list controls are strings, and you can use them as numbers if necessary (assuming that the string does contain a valid number). You can also do something else randomly, such as using the Len method of VBScript to check the length of a value that does not exist in the Request.Form collection. The Len function attempts to convert the value of a call from Request.Form to a string. If the value is lost, return null (EMPTY) and convert to a string with "", so the length is zero.
(7) VBScript data types and conversions
You can also make explicit data type conversions. In VBScript, the VarType method returns an integer indicating the currently saved subtype of the variant:
Select case VarType (varmyvalue)
Case 0:response.write "Empty (uninitialized)"
Case 1:response.write "Null (no valid data)"
Case 2:response.write "Integer"
Case 3:response.write "Long integer"
Case 4:response.write "single-precision floating-point number"
Case 5:response.write "double-precision floating-point number"
Case 6:response.write "Currency"
Case 7:response.write "Date"
Case 8:response.write "String"
Case 9:response.write "Automation Object Reference"
Case 10:response.write "Error"
Case 11:response.write "Boolean"
Case 12:response.write ' Variant (used only with the items in arrays of variants) "
Case 13:response.write "Data-access Object"
Case 17:response.write "Bytes"
Case 8192:response.write "Variant Array"
End Select
There are also functions, such as IsArray, IsDate, IsEmpty, IsNull, IsNumeric, and IsObject, that return a Boolean result for a specific subtype. Once you know the subtype of the data, you can convert it to a different variant subtype if the data contained is appropriate. This is useful for the transparency of the code and for checking whether the variable contains legitimate values, and the illegal conversion will result in a run-time error, as shown in the following conversions:
Blnboolean = CBool (varvariant) ' converts to a Variant of subtype Boolean
Bytbyte = CByte (varvariant) ' converts to a Variant of subtype Byte
Curcurrency = CCur (varvariant) ' converts to a Variant of subtype Currency
Dtmdate = CDate (varvariant) ' converts to a Variant of subtype Date
dbldouble = CDBL (varvariant) ' converts to a Variant of subtype Double
Intinteger = CInt (varvariant) ' converts to a Variant of subtype Integer
Inglong = CLng (varvariant) ' converts to a Variant of subtype Long
Sngsingle = CSng (varvariant) ' converts to a Variant of subtype
strstring = CStr (varvariant) ' converts to a Variant of subtype String
(8) JScript data types and conversions
In JScript, some other variable types are similar to VBScript, but there is no variant representing the object. All values are objects, and types are one of the following six data types:
· Undefined: Only a single value indicating that the variable in the request is not declared and created, or if it is implicitly created but has not yet assigned any value. Similar to the empty in VBScript.
· Null: The variable does not contain a valid value. Nothing similar to VBScript.
· Boolean.
· String.
· Number.
· Object.
JScript provides a typeof function that returns a string representing the type of data, for example:
strstring = ' 30 ';
Intinteger = 12;
Response.Write (typeof (Strstring)); Write ' string ' in the resulting page
Response.Write (typeof (Intinteger)); Write ' number ' in the resulting page
Each data type has the ToString method and the ValueOf method, and the ToString method returns the value of the variable to a string, valueof the value of the variable as its original data type.
(9) The cascading and adding problems of JScript
JScript differs in many ways from VBScript, partly because there are no "&" cascading operators available. When the addition operator is used, it first checks the data type of the variable to determine what to do. If all two variables are numeric, the result is the value of the and. If one or two are strings, the result is a cascading of strings:
strstring = ' 30 ';
Intinteger = 12;
Response.Write (Intinteger + Intinteger); Writes in the resulting



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.