VBScript (ASP) common functions

Source: Internet
Author: User
Tags key string random seed
No way. You need to write some asp files. Code Depressed. Put a function table for future reference.

VBScript (ASP) common functions:

1. Numeric functions:

ABS (Num): returns the absolute value.
SGN (Num): num> 0 1; num = 0 0; num <0-1; Positive and Negative values
Hex (Num): returns the hexadecimal value for direct representation: & hxx maximum 8 bits
Oct (Num): returns the octal value and indicates the maximum 8 bits of & oxx
Sqr (Num): returns the square root num> 0
INT (Num): integer int (99.8) = 99; int (-99.2) = 100
Fix (Num): Get the integer fix (99.8) = 99; fix (-99.2) = 99
Round (Num, n): rounded to the decimal place round (3.14159, 3) = 3.142 the midpoint value is rounded to the nearest even round (3.25, 1) = 3.2
Log (Num): returns the base-e logarithm num> 0.
Exp (n): The N power of e is usually num ^ n.
Sin (Num): trigonometric function, which is calculated in radians (angle * PAI)/180 = radian con (Num); Tan (Num); ATN (Num)

2. String functions:

Len (STR): calculates the length of a string. The length of a Chinese character is also counted as one!
Mid (STR, start character, [read length]): intercept the middle substring of the string
Left (STR, nlen): truncates the nlen substring from the left.
Right (STR, nlen): truncates the nlen length substring from the right.
Lcase (STR): converts a string to lowercase.
Ucase (STR): converts a string to uppercase.
Trim (STR): removes spaces at both ends of the string.
Ltrim (STR): removes spaces on the left of the string.
Rtrim (STR): removes spaces on the right of the string
Replace (STR, search string, replace string, [start character, replacement times, comparison method]): replace string Note: Default Value: Start character 1; no limit on replacement times; case sensitivity (0)
Instr ([start character,] STR, search string [, comparison method]): checks whether a sub-string contains optional parameters. You must select the return start position at the same time.
Reverse Rev (STR, query string [, start character] [, comparison method]): reverse detection of whether a substring is included
Space (n): string that constructs n Spaces
String (n, STR): constructs a string consisting of the first character of n str
Strreverse (STR): reverse string
Split (STR, split string [, times] [, comparison method]): Convert string into character array using the separator string

3. Data type conversion functions:
CINT (STR): Convert positive values to true-1; false 0; Date distance to 1899/12/31; time in the morning segment 0; afternoon segment 1;
CSTR (STR): Date output format: yyyy/mm/DD; Time Output Format: AM/PM hh: mm: SS
Clng (STR): similar to CIN ()
Cbool (Num): num is not zero. True; false
Cdate (STR): Format of the conversion date 0: # Am 12:00:00 #; date with a positive number ranging from 1899/12/31 days; floating point date + decimal time
Cbyte (Num): num <255 to bytes
Csng (STR): convert to a single-precision value
Cdbl (STR): convert to a double-precision value
Ccur (STR): Convert to cash format

4. Time functions:
Date: the current date of the system.
Time: the current system time.
Now: The datetime type of the current system time and date value.
Timer: the time difference between the current time and the zero second value. The timer can calculate the time difference.
Dateadd (interval unit, interval value, date): Calculate the adjacent date
Datediff (interval unit, date 1, date 2): Calculate time difference date 2-date 1
Datepart (interval unit, date): calculates the interval unit value of the date.
Dateserial (date): Output date value (calculated by sequence)
Timeserial (time): Output Time Value (calculated by sequence)
Datevalue (datetime): extracts the date value from the string.
Timevalue (datetime): retrieves the time value from the string.
Weekday (date): Calculate the day of the week
Monthname (date): name of the output month
Year (datetime): specifies the year to be truncated.
Month (datetime): truncate month
Day (datetime): truncate day
Hour (datetime): hour intercepted
Minute (datetime): capture minutes
Second (datetime): truncation second

5. Other functions:
Array (unit,...): dynamically generates an array
ASC (STR): the ASCII code of the first character of the output string.
CHR (ASC): Convert ASCII to enter: CHR (13) & CHR (10)
Filter (array name, key string, [, include] [, comparison method]): saves elements containing key strings in the string array into a new array (default) if the value [include] is false, the excluded elements are obtained.
Join (arrayname): concatenates elements in the array into strings.
Ubound (arrayname [, dimension]): obtains the upper bound of the corresponding dimension of the array.
Lbound (arrayname [, dimension]): the lower bound to obtain the corresponding dimension of the array is generally 0.
Randmize N: Start Random Seed
RND (n): obtain a random number. n> 0 or null. Obtain the next random value of the sequence. n <0. The random value is the same. n = 0, produce the same number as the previous random value and take the random positive number C between A and B, formula: c = int (B-A + 1) * RND +) condition (B>)

Examples of common statements for six ASP objects:

Response:

Response. Write strvar/"string": Writing parameter values or strings to a webpage is equivalent to embedding them in HTML tags.
Response. End: Stop page compilation and output the compiled content to the browser.
Response. Buffer = true | false: whether to use cache settings during page compilation. This is generally set in the page header.
Response. Flush: forces the output of partially compiled page content
Response. Clear: clears data in the buffer.
Response. Redirect URL: Stop page compilation or output and reprint the specified page
Response. isclientconnected: returns true | false to check whether the user is still connected.
Response. charset (charsetname): sets the page encoding type, that is
Response. contenttype [= contenttype]: Set the page file type, same as above
Response. expires [= number]: Set the page expiration time, in minutes
Response. expiresabsolute [= [date] [time]: sets the absolute time when the page fails.
Response. Status = statusdescription: sets the page status description.

Request:

Request ("passstrname"): Read the webpage transfer value, including the form and? Passstrname = Value & passstrname_n = value_n form
Request [. Collection | property | method] (variable)
Request. querystring ("passstrname"): Read the form value passed by the get method and? Passstrname = Value
Request. querystring (varible) [(INDEX). Count]
Request. Form ("passstrname"): Read the value of the pure form field passed by the POST method.
Request. Form (parameter) [(INDEX). Count]
Request. servervaribles (server environment variable): Read the environment variables of the client system. For details, see references.
Request. binaryread (count): Read the transfer value of the specified number of bytes
Request. totalbytes: the length of the query body, in bytes, read-only

Note: For a form with the same name, if checkbox has multiple values, an array is passed.

Session: (User global variables)

Session ("sesname") = value: stores the session variable value, which can also be read.
Session ("sesname") = empty: two methods to determine whether the session value exists
Isempty (Session ("sesname") = true | false: two methods to determine whether the session value exists
Session. Timeout = num: Set the validity period of the session variable, in minutes
Session. Abandon: Clear all session variable values
Session. sessionid: Id serial number of the session variable, read-only

Application: (ApplicationProgramGlobal variable)

Application ("appname") = value: stores the value of the application variable. You can also read this value.
Application ("appname") = empty: two methods to determine whether the application value exists
Isempty (Application ("appname") = true | false: two methods to determine whether the application value exists
Application. Lock: the value of the application variable is locked to prevent changing the value at the same time.
Application. Unlock: Unlock the value of the application variable, allowing you to change the value.

Note: Both session and Application variables can be used to store arrays and system objects. The reference method is that the variable name is equivalent to the array name,
However, the value cannot be changed directly. You need to use the temporary array to modify the value and then assign it to the session and Application variables.

Server:

Server. mappath ("fileurl"): the absolute address of the server site mapped to the file name. Path = server. mappath (./) can obtain the root path of the virtual directory.
Server. htmlencode ("string"): converts to HTML-formatted strings, such as: <,>.
Server. urlencode ("string"): Convert to browser address encoding.
Set Var = server. creatobject ("objname"): creates an object variable.
Server. scripttimeout = numseconds: time limit for executing ASP program pages, in seconds

Cookies: temporary variables stored on the user's local machine. The maximum size of each cookie is 4 kb. A maximum of 300 cookies can be 1.2 MB.

Response. Cookies ("strcookiename") = value: stores the cookie variable value, which can also be read.
Response. Cookies ("strcookiename") = "": determines whether it is empty.
Response. Cookies ("strcookiename"). expires = Date: The variable validity period, in days. The variable is invalid immediately when it is less than the current time.
Response. Cookies (cookie [(key). Attribute]): standard syntax

Objectcontext controls ASP Transaction Processing

Objectcontext. ontransactionabort: triggered by the abandoned Transaction Processing Event, which occurs after the script completes processing.
Objectcontext. ontransactioncommit: triggered by a successful transaction processing event.
Objectcontext. setabort: explicitly discard a transaction
Objectcontext. setcomplete: overwrite any previous call to the objectcontext. setabort method.

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.