Problem: Scripts using global variables do not compile

Solution or Workaround

Some scripts do not compile when opening a project.


ArcView is unable to compile scripts that contain a reference to a global variable if that global variable has not yet been defined.


ArcView compiles the scripts contained in a project in alphabetical order every time the project is opened. If you write script A using global variables that are defined in script B, and you save them, the next time you open your project script A will fail to compile because B has not been compiled yet and thus the global variables have not been defined.

There are two ways you can ensure all scripts using global variables will compile upon opening a project:

1. Name your scripts in such way that a script that defines a global variable alphabetically precedes any script that references that variable.

2. A better method is to create a script that defines all global variables as nil. Name this script such that it will be the first to compile. This way all global variables will be defined regardless of the order in which all other scripts are compiled. Global variables can be defined like this:

_global1 = nil
_global2 = nil
_global3 = nil