# Global/External Variables

> [HTML Version](globalexternalvariables.htm)

By default, only variables defined within the function or procedure (i.e. [Local Variables](localvariables.md)) are accessible within that routine. This is generally a good thing, as it helps prevent inadvertent references to the wrong variables, as well as unintended side-effects from calling a function or procedure. But the ability to access variables defined outside the routine can be enabled, by any of the following methods: 

•	**Private Map:** You can share variables between a group of related functions or procedures by grouping them all within a single file and declaring the shared variables at the top of the file using PRIVATE MAP statements. See [MAP Statement Extensions](variablescope.md).

•	[AUTO\_EXTERN](auto_extern.md)** **may be used to expose all global variables.

•	**EXTERN\_BEGIN, END:** You can expose a list or block of global variables by repeating the original MAP statements for those variables within the function or procedure, enclosed by ++PRAGMA EXTERN\_BEGIN and ++PRAGMA EXTERN\_END, e.g.

\++PRAGMA EXTERN\_BEGIN 

MAP1 SOME'VAR,F,6

MAP1 ANOTHER'VAR,S,20

\++INCLUDE MOREVARS.MAP

\++PRAGMA EXTERN\_END



•	[EXTERN](extern_statements.md)** **may be used to expose individual global variables.

**Subtopics**

- [AUTO\_EXTERN](auto_extern.md)

- [EXTERN](extern_statements.md)

- [.EXTERN()](extern().md)