Keyword

# Global

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Identifies the <span class="title-ref">Global</span> scope, making it possible to refer to items that might otherwise be ambiguous.

## Usage

``` xojo
Global.identifier 
```

## Notes

<span class="title-ref">Global</span> works similarly to `Self</api/language/self_keyword>`, `Me</api/language/me>` and `Super</api/language/super>` and is most useful when working with namespaces. You use it to refer to a <span class="title-ref">Global</span> identifier (such as a module or namespace) that might otherwise be inaccessible because they are hidden by local identifiers (i.e. methods or variables) in the current scope.

When using <span class="title-ref">Global</span>, assigning values to properties is not supported.

## Sample code

In this example, there is a module named *Utility* and another named AppInfo. Inside AppInfo there is a variable also named *Utility*. Code written in any method of the AppInfo module would assume implicitly that Utility refers to the local variable rather than the module. By adding the <span class="title-ref">Global</span> keyword prefix, you are being explicit that you mean the module rather than the local variable:

``` xojo
Module Utility
  Protected Version As Integer
End Module

Module AppInfo
  Protected Version As String

  Protected Sub GetAppInfo()
    ' Get the value of Utility.Version and assign it to our local Version
    Version = Utility.Version.ToString

    ' But now we have a local variable named utility, which shadows module Utility!
    Var utility As Color

    ' In order to reach the Utility.Version, we must explicitly back out to the global scope
    Global.Utility.Version = utility.Hue.ToInteger

    ' The first assignment can also be rephrased like this:
    Global.AppInfo.Version = Global.Utility.Version.ToString
  End Sub
End Module
```

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |
