Variable Utilities

SetVar

Purpose:

Assign a value to a variable.

Category:

Variables

Syntax:

SetVar "variable" "value"

variable

The name of a variable.

value

The value (text, number, etc.) to assign to the variable. To delete an existing variable, leave the value parameter empty.

Example:

In the example below, the variable [Price] is set to "49.95" and the variable [Name] is set to "Ralph Jones":


SetVar "[Price]" "49.95"
SetVar "[Name]" "Ralph Jones"


You may also use SetVar to modify or combine existing variables. For example:


SetVar "[FullName]" "[LastName], [FirstName] [MiddleName]"
SetVar "[DisplayPrice]" "$[Price]"


Normally, if value contains a valid mathematical formula, VisualNEO for Windows will compute the formula and store the results in the variable. If for some reason, you want the variable to contain the actual formula instead of formula's computed result, insert an exclamation point “!” at the beginning of value. For example, the following statement:


SetVar "[Test]" "1+1"


will set the variable [Test] to "2". This is because VisualNEO for Windows knows that "1+1" is a mathematical equation and adds the two numbers together. By adding an exclamation point you can instruct VisualNEO for Windows to ignore the formula. For example:


SetVar "[Text]" "!1+1"


will set the variable [Test] to "1+1". (Note: The exclamation point is removed by VisualNEO for Windows.) You can use this technique in any VisualNEO for Windows Action where numeric parameters are allowed.


DefineVar

Purpose:

Define a typed variable.

Category:

Variables

Syntax:

DefineVar "variable" "type" "format" "scope" "value"

variable

The name of the variable to be defined.

type

One of the following:


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 displayed with the number of decimals specified by format.

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.) below.


format

For decimals this parameter is the number of decimal places. For dates, format is composed from the items below separated by the “/” character:


d

Show the day as a number without a leading zero (1-31).

dd

Show the day as a number with a leading zero (01-31).

m

Show the month as a number without a leading zero (1-12).

mm

Show the month as a number with a leading zero (01-12).

yy

Show the year as a two-digit number (00-99).

yyyy

Show the year as a four-digit number (0000-9999).

Default

Use the system’s default date format.


For example, entering “d/m/yyy” will result in a date formatted as Day/Month/Year or “3/15/2007” The format parameter is ignored for all other variable types.

scope

One of the following:


Global

The variable exists until it is explicitly deleted or the publication closes.

Local

The variable exists only while the current script is executing. When the current script ends, the variable is automatically deleted.


value (optional)

An initial value to assign to the variable. Must be compatible with the selected type.

Example:

Example:


DefineVar "[Birthdate]" "Date" "m/d/yyyy" "Global" "1/1/1980"


In order to delete a variable created with DefineVar, you must first re-declare the variable as “Undefined”, then clear it with SetVar. For example:


DefineVar "[Birthdate]" "Undefined" "" "Global" ""
SetVar "[Birthdate]" ""


SaveVariables

Purpose:

Save the contents of all existing variables to a file. Use this Action to save a publication’s entire complement of variables at once. Since variables reside in memory and are cleared when a publication closes, you can use SaveVariables and LoadVariables to remember publication settings between sessions.

Category:

Variables

Syntax:

SaveVariables "file name"

file name

The name of the file to store the variable data.

Example:

SaveVariables "mypub.var"


LoadVariables

Purpose:

Load variables from a file previously created with SaveVariables. Use this Action to load an entire group of variables at once. Since variables reside in memory and are cleared when a publication closes, you can use SaveVariables and LoadVariables to remember variables between sessions.

Category:

Variables

Syntax:

LoadVariables "file name"

file name

The name of an external file containing the variables to be loaded.

Example:

LoadVariables "[PubDir]MyPub.var"


ClearVariables

Purpose:

Clear variables from memory.

Category:

Variables

Syntax:

ClearVariables "variable list"

variable list

A list of a list of variables to be cleared. Separate multiple variables with comma or pipe “|” characters. Leave this parameter blank to clear all variables.

Example:

The following example will clear all variables in the publication:


ClearVariables ""


The following example will clear only those variables listed:


ClearVariables "[FirstName],[LastName],[Street],[City],[State],[Zip]"


DeleteArray

Purpose:

Delete an array of variables.

Category:

Variables

Syntax:

DeleteArray "array name" "array size"

array name

The name of the array variable to delete.

array size

The number of elements to delete or “All” to delete the entire array.

Example:

DeleteArray "Clients" "All"


GetArrayInfo

Purpose:

Count the number of items in a variable array. Returns the array’s upper and lower bounds plus total number of items in array.

Category:

Variables

Syntax:

GetArrayInfo "array name" "min var" "max var" "size var"

array name

The name of the array variable to examine.

min var

The variable to store the index of the lowest element in the array.

max var

The variable to store the index of the highest element in the array.

size var

The variable to store the total number of elements in the array.

Example:

GetArrayInfo "[Names]" "[Low]" "[High]" "[Size]"