24.12.2012 Views

ER/Studio - Embarcadero Technologies Product Documentation

ER/Studio - Embarcadero Technologies Product Documentation

ER/Studio - Embarcadero Technologies Product Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

AUTOMATING <strong>ER</strong>/STUDIO ><br />

When an entity is created, <strong>ER</strong>/<strong>Studio</strong> calls the CreateEntityHandler( ) function in the<br />

<strong>ER</strong>SBasicHandlers.bas file.<br />

When the function is called, <strong>ER</strong>/<strong>Studio</strong> passes to the handler the newly created entity (the current entity) and the<br />

current diagram. The bodies of all the functions in the file are currently empty. You can extend the creation behavior of<br />

any of the objects listed above by implementing the bodies of these functions.<br />

Example:<br />

NOTE: <strong>ER</strong>/<strong>Studio</strong> does not call the creation event functions for attributes and indexes until after you exit<br />

from the Entity Editor.<br />

Sub CreateEntityHandler(CurEntity As Object, CurDiagram As Object)<br />

Dim Prefix as String<br />

Dim EntityName as String<br />

Dim NewEntityName as String<br />

Prefix = "<strong>ER</strong>S"<br />

EntityName = CurEntity.EntityName<br />

NewEntityName = Prefix + EntityName<br />

CurEntity.EntityName = NewEntityName<br />

End Sub<br />

In this example, the CreateEntityHandler function is modified so that a prefix of <strong>ER</strong>S is attached to the default entity<br />

name each time you create a new entity.<br />

Here is a more detailed explanation:<br />

When you use the Entity Tool to create an entity, the default name for the entity is EntityX, for example, Entity1,<br />

Entity2. By modifying the body of the CreateEntityHandler function in the manner shown above, the default entity<br />

name becomes <strong>ER</strong>SEntityX (e.g. <strong>ER</strong>SEntity1, <strong>ER</strong>SEntity2).<br />

Notes<br />

• When <strong>ER</strong>/<strong>Studio</strong> starts, it reads in all the creation event handler functions from the file <strong>ER</strong>SBasicHandlers.bas.<br />

Modifications to these functions while the application is running will have no effect. You must restart <strong>ER</strong>/<strong>Studio</strong> for<br />

your modifications to take effect.<br />

• You cannot declare a specific object type (for example, Entity) in the creation event handler functions. All objects<br />

must be declared as the generic Object type.<br />

See Also<br />

Related Topics<br />

Handling Update Events<br />

You can customize the Entity update template subroutines.<br />

To enable this option, click Tools > Options > Automation Options and then select Update Handlers.<br />

EMBARCAD<strong>ER</strong>O TECHNOLOGIES > <strong>ER</strong>/STUDIO® 8.0.3 US<strong>ER</strong> GUIDE 310

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!