Working with Variable Parts

The following tasks are associated with using a Variable part in visual composition. Tasks that are common to many parts are described in related topics.

Setting the object type
To specify the object type that the variable can hold, open the Variable pop-up menu. Then, select Change type and enter the object type you want. After you change the variable type, you can connect to part interface features of the new type.

To have the Variable hold objects defined by a template class, you must specify the template arguments. For example, for a sequence of ICustomer instances, specify IVSequence<ICustomer*> *.

If you examine generated code for Variable parts, you will observe that their implementation varies. This variation depends on the object type you specify, and is based on the following factors:

Considering these factors, the Variable part is implemented as follows:


Pointer specified?
Object part type Yes No
Visual IVBVariablePartPointer* IVBVariablePart*
Nonvisual IVBVariablePartPointer* IVBVariablePart*
Class interface IVBVariableClassPointer* IVBVariableClass*

Changing the variable name
To change the variable name to something meaningful for your application, open the Variable pop-up menu. Then, select Change name and enter the name you want.

Assigning an object to a variable
To assign an object to a variable, connect the this attribute of a part instance of the same part type to the this attribute of the variable.

Initializing attributes for connections
To specify how attributes are initialized for connections when a new object is assigned to a variable, set the initializationType property in the part property sheet. The default value is broadcast. Select one of the following choices in the value column:

Specifying when attribute changes are applied for connections
Value updates for attribute-to-attribute connections can be applied to variable attributes as the changes occur, or the updates can be deferred. To specify whether updates are deferred, set the deferUpdate property in the part property sheet. The default value is false.

If the property value is true, updates are deferred. To apply deferred changes, make a connection to the variable'sapply action. This action directs the variable to update its attributes for all attribute-to-attribute connections.

Automatically deleting an object in a variable
Variables typically hold dynamically created objects that should be deleted in the following circumstances:

To automatically delete a dynamically created object in a variable, set the autoDeleteTarget property in the variable's property sheet. Select true in the value column


Related procedures
Working with VisualAge User Interface Parts

Related references
Variable
Property Settings -- Variable
Portability -- Variable