8 6 2 DEFINE_MAP with DEFINE_EVT

LANSA Technical

8.6.2 DEFINE_MAP with DEFINE_EVT

Unlike standard events such as Click or Initialize, user-defined events can also receive values. To specify the value to be passed to the event, add a DEFINE_MAP statement after the DEFINE_EVT statement.

Let's use a form called Form B as an example. It has a user-defined event EMPLOYEE_CREATED which is signaled when the user has created a new employee record. The DEFINE_MAP statement defines that the event will also receive the employee number of the newly added employee.

This is the DEFINE_EVENT block in Form B:

define_evt name(employee_created)
define_map *input class(#empno) name(#this_emp)
 

FormB also has a SIGNAL command which signals that the event has been triggered and passes the employee number of the new employee to the event routine:

signal event(employee_created) this_emp(#empno)
 

The owner form of  Form B has an event routine for the employee_created event which receives the employee number and maps it to a variable #TheValue and then assigns this value to field #empno on the owner form.

EVTROUTINE HANDLING(#FormB.employee_created) this_emp(#TheValue)
   set com(#empno) value(#TheValue)
ENDROUTINE