O'Reilly logo

VBScript in a Nutshell, 2nd Edition by Ron Petrusha, Matt Childs, Paul Lomax

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

ExecuteGlobal Statement

Syntax

ExecuteGlobal statement
statement

Use: Required

Data Type: String

A string expression containing zero or more statements for execution.

Description

Executes zero or more statements in the global namespace of a script.

Rules at a Glance

  • statement must evaluate to a string containing one or more executable statements. An executable statement is any call to a user-defined procedure or function, or to an intrinsic VBScript command.

  • If statement contains multiple statements or lines of code, you can separate them with colons.

  • You can also separate statements or lines of code with embedded line breaks (i.e., vbCrLf).

  • If statement includes an equal sign, it is interpreted as an assignment rather than an evaluation. For example, x = 3 assigns the value 3 to the variable x, rather than comparing the value of the variable x with 3.

  • Code created by ExecuteGlobal is executed in the script’s global namespace. The global namespace is the following:

    • In ASP and IE, code within a <SCRIPT>...</SCRIPT> tag, but outside of individual functions or procedures.

    • In Outlook, form-level code outside of individual event handlers, functions, or procedures.

    • In WSH, code outside of individual functions and procedures.

Example

The example WSH script illustrates the difference between Execute and ExecuteGlobal. Each is called within the MainProc procedure to define a subroutine. Execute creates a procedure named Proc2; however, it is only visible if called from MainProc. ExecuteGlobal creates ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required