Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the differences among Eval, Execute and ExecuteGlobal

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what are the differences between Eval, Execute and ExecuteGlobal". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "what are the differences between Eval, Execute and ExecuteGlobal?"

Syntax: [result=] eval_r (expression_r)

Expression_r is a string of any valid VBScript expression

Example:

The code is as follows:

Response.Write (eval_r ("3x2")) 'output 5

"3percent 2" is enclosed in quotation marks to indicate that it is a string, but in Eval's "eyes", it is executed as an expression 3percent 2.

Execute executes one or more specified statements. Multiple statements are separated by a colon (:).

Syntax: Executestatements

Example:

Execute "response.Write ("abc")" 'outputs abc

"response.Write ("abc")" is enclosed in quotation marks to indicate that it is a string

But in Execute's "eyes", it is executed as a statement response.Write ("abc").

ExecuteGlobal executes one or more specified statements in the global namespace.

Syntax: ExecuteGlobalstatement

What's the difference among Eval, Execute and ExecuteGlobal?

Example:

The code is as follows:

Dimc

C = "global variable"

SubS1 ()

Dimc

C = "local variable"

Execute "response.Write (c)" 'outputs local variables

ExecuteGlobal "response.Write (c)" 'outputs global variables

Endsub

Execute "response.Write (c)" 'outputs global variables

CallS1 ()

The variable c is defined in both the global scope and the function scope. Execute decides to use local variables or global variables according to its location, while ExecuteGlobal always recognizes only the global scope c.

Summary:

Eval executes only one statement statement with or without a return value

Execute executes one or more statements to ignore the return value of the statement

ExecuteGlobal always uses global variables when executing one or more statements ignoring the return value of the statement when global variables and local variables have the same name

Note:

In VBScript, both "assignment" and "comparison" use "=". For example, "aquib" can be said to assign a value to a, or to judge whether an is equal to b, so does eval_r ("aquib") mean assignment or comparison operation?

Here's a convention: in Eval, "axib" always means comparison, and in Execute and ExecuteGlobal, it always means assignment.

At this point, I believe you have a deeper understanding of "what is the difference between Eval, Execute and ExecuteGlobal". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report