Accessing the Variables Database

To access the Variables database, select:

Edit -> Variables

The following screen is displayed:

Figure 5-1. Variables Database Menu Page

Variables Database Record Options

1

Enter a name string for the variable or symbolic constant to be defined. Enter a real number to define a real constant.

2

Indicate whether this record should belong to a group. This option is for convenience in sorting variables in the various pick lists (variables are sorted first by Group and then by record name). It does not affect the behavior of the variable. The Variables Index pop-up shows all local-to-sequence variables. It also displays the sequence and group names with lines between each group for clarity.

3

Enter a description of the variable.

4

Displays the value defined for the variable. If the data type selected is an AIM variable (string or numeric), this field is also used to enter the value. Question marks in the value field indicate that the variable has not been defined.

5

Displays statistical information. See Statistics for details.

6

Define the data type and units for this record. The default data type is numeric - AIM variable. Click Define to define a different data type.

Table 5-1. Data Type Definitions
Select...
to define...

constant - Integer

a symbolic constant value that can have only an integer value, e.g., 112.

constant - Input signal

an input signal. This value must represent a valid, installed digital input signal, e.g., 1003 (or a soft signal).

constant - Output signal

an output signal. This value must represent a valid, installed digital output signal, e.g., 7 (or a soft signal).

constant - Real value

a symbolic constant value that can have a real value, e.g., 12.635.

numeric - AIM variable

a real variable that can be changed by an executing AIM sequence.

numeric - ai.ctl

[ ] value

a real variable that accesses the special AIM control values.

numeric - Database field

a real variable that refers to a database field that is a numeric type (byte, integer, or real).


The database field feature allows an AIM variable to be associated with a field in another database. When the variable is accessed, the specified database field is actually read from or written to. You can use the fields to specify the database record. If these fields are left blank, the SELECT_VAR_REC statement must be used to specify the record.

numeric - V+ variable

a real variable that can be changed by an executing V+ program. The value is stored in a V+ global variable.

numeric - Vision result

a real variable that is associated with a vision inspection record result. It is a read-only type. The results of any vision inspection may be specified and then processed in a sequence program.


You must supply the Vision record name in the Record field or a linking error will be reported.

string - AIM variable

a variable that contains a string value. The value is stored in the AIM Variables database. The string may be up to 128 bytes long. String variables may be used in the SETS statement or the I/O server statement.

string - Database field

a string variable that refers to a database field that is a string type (string or name).

string - V+ variable

a variable that contains a string value. The value is stored in a V+ global string variable. The string may be up to 128 bytes long. String variables may be used in the SETS statement or the I/O server statements.

6

Define the data type and units for this record. The default data type is numeric - AIM variable. Click Define to define a different data type.

7

This area defines the sequences that will have access to the variable (known as variable scope). If the record being accessed is in a Variables database which is part of a resource module, the variable can be:

Local to module
Variable accessible by all sequences in the module.

Local to sequence
Variable accessible only by a specific sequence.

8

Select Read to allow DDE read access to the variable information by an external WindowsTM application such as Microsoft Excel.TM

Select Write to allow DDE write access to the variable information by an external WindowsTM application such as Microsoft Excel.TM

 

9

The following Definition items are displayed based on the data type selected:

Read/write Allows read/write access to the variable record.

Read only Allows read-only access to the variable record.

Output signal number
The output signal number (used when constant - Output signal is selected).

Global only Refers to the Database field.

Database: The type of the database accessed by a numeric or string valued Database field variable.

If Global only is selected, the global database of this type is always accessed.

If Global only is not selected, the database of this type in the resource module is accessed. If the resource module does not have a database of this type, the global database is accessed.

Record: The record number to access in the specified database. If this field is left blank, the system accesses the last record selected by the SELECT_VAR_REC statement. See the SELECT_VAR_REC Statement for details.

Field: The field name to access in the specified database.

Index: The index number that corresponds to the specified field name in the database.

Result: For numeric - Vision result data type only. Displays the result of the specified vision record. You must supply the vision record name (in the Record field) or a linking error will be reported.

Value: For constants and input/output signals, enter the value for this variable. This value cannot be changed except by editing it from the variable record.

For variables and ai.ctl[ ] values, displays the current value of this variable. Question marks indicate that the variable has not been defined.

 

A Note on Data Conversion

In most places, AIM allows you to specify string or numeric values interchangeably. If you use a string-type variable where AIM expects a numeric value, AIM uses the V+ VAL( ) function to extract the leading number from the string and uses that value in the computation. If the string does not begin with a number, AIM uses zero. If you use a numeric value where AIM expects a string, AIM uses the V+ default numeric encoding (/D format) to create a string value (except that there is no leading blank in the string). The computation continues with that string. This feature is illustrated in the following example:

Assume we have the numeric variables n1, n2, and n3, and the string variable s1. You can write a sequence to set n3 equal to the numeric value 12:

		SET n1 = 1
		SET n2 = 2
		SETS s1 = n1+n2	;Concatenate the string
		SET n3 = s1	;Convert the string value to a numeric value 

SELECT_VAR_REC Statement

This statement dynamically selects a database record for use by the variable database for the current runtime task.

The syntax is:

	SELECT_VAR_REC --database-- {GLOBAL --yes/no--} RECORD
		--string_var-- {STATUS --o_variable--} 

Double-click --database-- to enter a standard database name for a runtime database. If GLOBAL is set to "yes", the global database of the specified type is used even if there is a database of this type in the current module.

RECORD --string_var-- is the name of a string variable that contains the name of the record to be found. If the record is found, STATUS --o_variable-- is set to TRUE; otherwise, it is FALSE.

Note that a different record may be selected for each database type. The selection made by each runtime task is independent of all others.

NOTE: The displayed value of the variable from Task 3 (menu driver) may not be the value for the task that is using the SELECT_VAR_REC statement. This is true for AIM variables that are linked to a database because each task can retrieve a different value based on this statement.