beautypg.com

Events, Concept – Kofax DOKuStar Validation User Manual

Page 39

background image

DOKuStar Validation Programming Manual

Page

35

Events

Concept

Certain objects can get events. You will probably use the events defined for the

FieldType

and the

DocumentType

object, but there are many more objects which have the ability to get events. For example, an

event may be assigned to a single

Field

(instead of the

FieldType

), e.g. to the amount field on the first document.

So you could add code that would be executed if the user changed the amount on the first document, but not, if he
changed the amount on one of the following documents.

This manual will not describe every event for every object, but concentrates on the most important items. To see the
complete list, refer to the reference help file, or use VBA‘s object browser: Open the VBA development studio, press

F2

and select the

DOKuStarValidation

library.

DOKuStar Validation event handling routines use a special naming scheme:

They all begin with

On

... and end with ...

ing

, ...

ed

or

…ingCanceled

. For example, consider the

OnFieldChanging

,

OnFieldChanged

and

OnFieldChangingCanceled

event. For most events, you

will always have such a group of three events.

Rules:

The ...

ing

event always comes first and can be aborted by the scripting routine. If the scripting routine wants to

abort the event, it must return

False

, else

True

. So, for the

OnFieldChanging

example, this event means: “The

value of the field is about to be changed. Any Objection?”

When

True

is returned, you will next get the

…ed

event, in our case the

OnFieldChanged.

This event

indicates, that the changing of the field now took place. Contrarily, when

False

was returned in the

…ing

you will

next get an

…ingCanceled

, indicating that the changing of the value was canceled.

Note that when you return

False

in the ...

ing

event, all events that might follow will not be fired (except the

Canceled

event); especially, you will not get the corresponding ...

ed

event.

In the example above the

OnFieldChanging

event was used, since we wanted to abort the changing in some

situations. If the

OnFieldChanged

event had been used, the old contents could not have been restored.

Consequently, event handling routines for ...

ing

events are always functions that return a Boolean, while ...

ed

routines are always subroutines.

When writing an event handling routine, proceed as follows:

-

Define a variable of the appropriate object type:

Dim WithEvents fld As FieldType

-

This variable will now appear in the drop down list above the editing window. Select it: