/ Forums / Advansys Formativ / Formativ Creator / Organizing Code with Classes / Reply To: Organizing Code with Classes

#5633
Support 1
Participant

    Unfortunately the mechanism used in Formativ to handle form/control events only supports standalone procedures. A VBScript class method cannot be an event handler.

    For the moment the only way I can see to organize your procedures is by form name. That is, when an event handler procedure is created, the designer automatically gives it a name based on its owner form, eg. where the form name is “MyDialog”:

    Sub MyDialogButton1Click(Sender)

    Then all handlers belonging to a given form will appear together, in alphabetical order, in the Procedures group of the Code Explorer (treeview of globals, classes, procedures).

    Note that it is possible to assign a handler to multiple events, even in different forms. This is useful when you want to perform the same action in different contexts. In this case I would try to keep things simple by giving the handler a general name. It may be appropriate for the handler to delegate to an object method (as with gMyClass.UpdateDateTime() in the above sample from Support 3), particularly if the object method is complex or depends on related methods/fields. In this way you can encapsulate much of the complexity inside a class. Obviously, a global reference to the object will be required, like the variable gMyClass.

    I hope this helps.

    Regards,
    Advansys Support