Creating variables in VisualNEO for Windows is easy, since you’re not required to allocate memory or explicitly define the scope of a variable prior to using it - although you can do that too if you want. In VisualNEO for Windows, anytime you make a reference to a variable, it’s created automatically. However, there are many situations where you might want to initialize a variable prior to using it. Suppose you have several default settings that you want to initialize when your publication first starts. VisualNEO for Windows’s SetVar Action is designed for this purpose. For example:


SetVar "[Name]" "Unknown"

SetVar "[Busy]" "No"

SetVar "[Amount]" "1.00"


It’s not necessary to delete variables since VisualNEO for Windows will do this for you when your publication closes. However, if your publication uses a large number of temporary variables, you may be able to improve performance by manually removing variables from memory when you no longer need them. You can do this using the SetVar Action to set the variable’s value to null or empty. Empty variables are automatically removed from memory by VisualNEO for Windows. For example:


SetVar "[Name]" ""

SetVar "[Busy]" ""

SetVar "[Amount]" ""


Defining Variables

In addition to the SetVar Action, VisualNEO for Windows provides another Action called DefineVar that can be used to create variables and restrict their contents to specific types of data. Generic, undefined variables, created with SetVar, don’t care what type of information they contain. It’s perfectly acceptable for a generic variable to contain text one minute and a number the next.


However, there are instances where experienced authors might want to limit the contents of a particular variable to text or numbers. For example, you might want to limit what can be entered into the “Age” field of a fill-in-the-blank form to numbers. By using the DefineVar Action to declare an [Age] variable as an “Integer” at the beginning of your publication, you can do exactly that. For example:


DefineVar "[Age]" "Integer" "" "Global" ""


If the variable [Age] is assigned to a Text Entry Object, then entering anything other than a number will generate an error message.


Other variable types that can be created with DefineVar are:


Undefined

The variable’s content is not limited. This is the same as a generic variable created with SetVar.

String

The variable can contain any characters either alpha or numeric.

Integer

The variable is limited to whole numbers.

Currency

The variable is limited to numbers and will be formatted as currency according to the regional settings in the Windows Control Panel.

Decimal

The variable is limited to numbers and will be formatted with the number of decimals specified.

Boolean

The variable is limited to “True” or “False” values.

Date

The variable is a date and will be displayed using the specified date format (m/d/y, etc.).


In addition to limiting a variable’s content, DefineVar can be used to format certain types of variables so that they are more readable. Currency and Decimal types will be formatted with a specific number of decimal places. Boolean variables will always be either “True” or “False.” Date variables can be displayed in a variety of ways depending on the formatting option specified in the DefineVar statement.