ASP Eval, Execute, Executeglobal differential Analysis _ Application Tips

Source: Internet
Author: User
Eval evaluates the value of an expression and returns the result.
Syntax: [result =]eval_r (Expression_r)
Expression_r is a string of any valid VBScript expression
Example:
Copy Code code as follows:

Response. Write (Eval_r ("3+2")) ' Output 5

"3+2" is enclosed in quotes, representing a string, but in the Eval "eye", it executes as an expression 3+2.
Execute executes one or more of the specified statements. Multiple statements are separated by a colon (:).
Syntax: Execute statements
Example:
Execute "Response. Write ("abc" ")" ' Output ABC
Copy Code
"Response. Write ("abc") is enclosed in quotes to indicate a string
But in Execute "the eye", treats it as a statement response. Write ("ABC") to perform.
Executeglobal executes one or more specified statements in the global namespace.
Syntax: Executeglobal statement
Example:
Copy Code code as follows:

Dim c
c = "global variable"
Sub S1 ()
Dim c
c = "local variable"
Execute "Response. Write (c) "' Output local variable
Executeglobal "Response. Write (c) "' Output global variable
End Sub
Execute "Response. Write (c) "' Output global variable
Call S1 ()

Variable c is defined both globally and within the scope of the function, where Execute decides whether to use local or global variables in its place, and Executeglobal always only recognize global scope C.
Summarize:
Eval executes only one statement statement can have or can not return a value
Execute executes one or more statements ignoring the return value of the statement
Executeglobal executes one or more statements ignores the return value of a statement global and local variables always use global variables when they have the same name
Attention:
In VBScript "Assignment" and "comparison" are used "=", such as "a=b" can be said to be a B value to a, or to determine whether a and B are equal, then Eval_r ("A=b") is to represent the assignment or comparison operations?
There is a convention that, in Eval, "A=b" always represents a comparison operation and always represents an assignment in both Execute and Executeglobal.

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.