ArtWonk modules within a Macro are unable to communicate directly with modules outside the Macro. Most of the time this is highly desirable because it makes organizing and tracking the connections in large patches much easier. However occasionally it is necessary allow modules to access values outside their local scope. For this ArtWonk provides the global Variable module.
For a general discussion of Variable modules in the context of all ArtWonk modules, see the Global Variables section of the Modules page. Global variables are not the same as the local Const and LocVar modules, which are regular modules that are only accessible at the local macro level.
Global variables exist in two parts, the variable data base which is global and accessible at any macro level, and the local variable module that accesses the global variable, which only exists at the local macro level. Global variables may contain either values or text.
To create a global Variable, right click on the Workspace and select Variable from the pop up menu. An unnamed read only variable will be created; in order to use it you need to set its properties, by clicking on the module's blue upper right Property button which pops up the Property dialog.
Global Variables must have unique names, so the first thing to do is give the variable a name (which will create a new variable) or select a variable already existing, with the drop down Name list box in the upper left corner of the property dialog.
To create a new name, and thus a new variable, simply type it in into the Name list box. Variable names may not be duplicated, even if you use different case. If you enter the name of an already existing variable an error message will pop up to that effect, giving you the option of canceling or of updating the parameters of all variables with the same name.
Whether selected from the list of existing variables or created anew, the module will take on the name of the variable, providing local access to the global variable.
Renaming a variable
Although variables must have unique names, you can rename a variable if you like. Use the Rename button at the bottom left of the dialog. All Variable modules with the old name will be updated to the new name.
Variables may be set to Read Only, Write Only, or Read Write. Variables are processed by their access modules, so when updating the variable with a Write Only or Read Write module type, be sure the update occurs earlier in the module calculation order than the modules that read the value. You can create what amounts to a global constant by entering the constant value in the Value field, and then accessing it with Read Only type variable modules.
Icon, labels, tool tips
Variable icon colors have no effect on the module, they exist only to provide visual grouping - you can set them to whatever color you like, or ignore them. When you change an icon color, label, or tool tip, all variable modules for that variable (e.g., that have the same variable name) will update to the same color or text.
Loading Macros that contain Variables
When a macro is loaded that contains global variables, if a global variable with the same name already exists, the macro module will use that variable; if it does not exist then loading the macro will cause the global variable to be created.
ArtWonk is Copyright © 2003-2014 by John Dunn and Algorithmic Arts. All Rights Reserved