executeglobal problem

Results 1 to 3 of 3

Thread: executeglobal problem

  1. #1
    Hud Guest

    Default executeglobal problem

    I hope someone can answer this one. I have am ASP program that calls an object. EVerything works fine like it&#039;s supposed to except one thing. I use executeglobal inside the object to execute a subroutine in the ASP script. The object is included in the ASP script via a include statment. It performs perfectly, except that a variable string that is passed back from the object is showing up blank inside the SUB, but everywhere else it is fine. It is not being blanked out anywhere. <BR><BR>Does executeglobal somehow prevent variables outside its "realm" be read from outside the sub? If so, what is a work around?

  2. #2
    Join Date
    Dec 1969

    Default What's executeglobal?

    Is that a function you wrote, or is that something that VB/C++/Java uses? I&#039;m not familar with it.

  3. #3
    Join Date
    Dec 1969

    Default RE: What's executeglobal?

    It&#039;s a VB script command. I figured out the problem. I needed to call the variable from the object INSIDE my sub. That&#039;s all. Whew! Took me long enough to guess that. <BR><BR>Anyway, here is what the VB script documentation says about executeglobal. It&#039;s a little known, but very powerful command. <BR><BR>ExecuteGlobal Statement<BR>Executes one or more specified statements in the global namespace of a script.<BR><BR>ExecuteGlobal statement <BR><BR>The required statement argument is a string expression containing one or more statements for execution. Include multiple statements in the statement argument, using colons or embedded line breaks to separate them. <BR><BR>Remarks<BR>In VBScript, x = y can be interpreted two ways. The first is as an assignment statement, where the value of y is assigned to x. The second interpretation is as an expression that tests if x and y have the same value. If they do, result is True; if they are not, result is False. The ExecuteGlobal statement always uses the first interpretation, whereas the Eval method always uses the second. <BR><BR>Note In Microsoft® JScript™, no confusion exists between assignment and comparison, because the assignment operator (=) is different from the comparison operator. <BR><BR>All statements used with ExecuteGlobal are executed in the script&#039;s global namespace. This allows code to be added to the program so that any procedure can access it. For example, a VBScript Class statement can be executed at run time and functions can subsequently create new instances of the class. <BR><BR>Adding procedures and classes at runtime can be useful, but also introduces the possibility of overwriting existing global variable and functions at runtime. Because this can cause significant programming problems, care should be exercised when using the ExecuteGlobal statement. If you don’t need access to a variable or function outside of a procedure, use the Execute statement which will only affect the namespace of the calling function. <BR><BR>The following example illustrates the use of the ExecuteGlobal statement: <BR><BR>Dim X &#039; Declare X in global scope.<BR>X = "Global" &#039; Assign global X a value.<BR>Sub Proc1 &#039; Declare procedure.<BR> Dim X &#039; Declare X in local scope.<BR> X = "Local" &#039; Assign local X a value.<BR> &#039; The Execute statement here creates a<BR> &#039; procedure that, when invoked, prints X.<BR> &#039; It print the global X because Proc2<BR> &#039; inherits everything in global scope.<BR> ExecuteGlobal "Sub Proc2: Print X: End Sub"<BR> Print Eval("X") &#039; Print local X.<BR> Proc2 &#039; Invoke Proc2 in Global scope resulting<BR> &#039; in "Global" being printed.<BR>End Sub<BR>Proc2 &#039; This line causes an error since <BR> &#039; Proc2 is unavailable outside Proc1.<BR>Proc1 &#039; Invoke Proc1.<BR> Execute "Sub Proc2: Print X: End Sub"<BR>Proc2 &#039; This invocation succeeds because Proc2<BR> &#039; is now available globally.<BR>The following example shows how the ExecuteGlobal statement can be rewritten so you don&#039;t have to enclose the entire procedure in the quotation marks: <BR><BR>S = "Sub Proc2" & vbCrLf<BR>S = S & " Print X" & vbCrLf <BR>S = S & "End Sub"<BR>ExecuteGlobal S<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts