Binding Commands, Introduction

4D - Documentation   Français   English   German   4D Draw 2004, Command Theme List   4D Draw 2004, Command Alphabetical List   Back   Previous   Next

version 6.0


The Binding theme commands and functions enable you to create and work with binds between objects in a 4D Draw area and fields in a database.

Object binding is a unique feature in 4D Draw that lets you establish a connection between objects in drawings and records in a database. Binding provides a way to associate the attributes of objects with field values. You can get the same results by using a series of 4D Draw and 4th Dimension commands to test and modify object attributes and field values. A bind, however, requires less code, is simpler to implement, and is more easily modified.

You can create any number of binds, but only one bind can be active for a given 4D Draw area at a time. To use a bind, you must first specify which attributes are to be bound to which fields. For more information, see the DR ADD TO BIND command.

Once a bind is activated, the fields take on the values of the attributes of the selected objects. If no objects are selected, the bound fields show the default values for the area. If only one object is selected, the bound fields show the values for that object. If more than one object is selected, the bound fields show the values that the objects have in common. If the objects are not the same for a given attribute, or if the attribute is inappropriate for the selected object, the bound field displays an error code. The error code is -32000, or another code, depending on the field type.

When the user makes an entry in a bound field, the objects' attributes are updated. If no objects are selected, the default values are set. If multiple objects are selected, they are all updated.

Some attributes cannot be modified. If the user attempts to modify a field bound to a non-modifiable attribute, the field's value is reset to its former value. Fields that are bound to non-modifiable attributes should be non-enterable. See Appendix A, Attribute Codes for a complete list of attribute codes and corresponding field types.

Much of the information used in a bind is numeric. For example, a field bound to the fill pattern returns the number of the pattern in the palette. To determine the meaning of the values in the bound fields, see the commands that affect that attribute. For example, to determine how to interpret or set a fill pattern, see the DR GET FILL ATTRIBUTES or DR SET FILL ATTRIBUTES command.

Coordinate and size attributes are specified in scale units according to the origin. This matches what the user sees in the Coordinates panel. Use the DR Scale to base function to convert from scale units to base units.

Binding always affects the values in the current record. If there is no current record, the bind has nothing to affect.

To create a binding method in the User environment:

1. Select the object(s) for which you want to activate a bind.

2. Choose Binding from the Database menu.

The Binding dialog box appears.

3. Choose an attribute from the Attribute pop-up menu.

4. Choose a table from the pop-up menu of tables.

The fields for the selected table are displayed.

5. Choose a field to which to bind the 4D Draw attribute.

6. Choose a bind direction from the Activation area:

Attributes to Fields: When you modify the objects in the 4D Draw area, the value of the field changes.

Fields to Attributes: When you enter a value in the field, the objects in the 4D Draw area are modified.

7. Click Add to add the bind to the Current Binds list.

The bind will be activated when you click the OK button. If you want to use the bind within your database, you must copy the bind code into a method in the Design environment.

8. Click the Copy button to copy the binding method to the Clipboard.

When you click the Copy button, the following dialog box appears:

9. Enter the variable name you wish to use for the bind and click OK.

This variable name is used in the commands 4D Draw creates. The commands are copied to the Clipboard, from which you can paste them directly into a method window.

The bind information copied to the Clipboard defines the bind you created in the dialog box. For instance, the Clipboard might contain the following lines:

   vBind := DR New Bind
   DR ADD TO BIND (vBind;6;1;3)
   DR ADD TO BIND (vBind;5;1;4)
   DR ADD TO BIND (vBind;11;1;5)

To make the method work, you must add an additional line of code to activate the bind. The statement that activates the bind specifies whether the bind should go from the drawing to the fields or from the fields to the drawing.

In the following method, the statement:

   DR ACTIVATE BIND (Picture;vBind;2) 

is added to activate the bind. The last parameter to the command indicates that the bind should go from the fields to the drawing.


4D - Documentation   Français   English   German   4D Draw 2004, Command Theme List   4D Draw 2004, Command Alphabetical List   Back   Previous   Next