HOW TO

Determine if a global variable has been declared and return its value.

Last Published: April 25, 2020

Summary

The sample script in this article determines if a global variable exists, and if so, it will return the value of the variable.

Procedure



  1. Open a new script window.

    A. Activate the Project window.
    B. Click the Scripts icon.
    C. Click New.

  2. Copy the following code into a script window.

    Code:
    '-- Substitute "_myGlobal" with your global variable.

    '-- See if _myGlobal has been defined

    s = Script.Make( "x = _myGlobal" )

    If (s.HasError) then
    MsgBox.Error( "The global variable doesn't exist", "")
    Else
    MsgBox.Info("Value = "+ _myGlobal.AsString,"The global variable exists!")
    end

  3. Click the Compile button.
    [O-Image] Script compile button
  4. Click the Run button.
    [O-Image] Run compiled script button

Article ID:000004179

Software:
  • Legacy Products

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options