The previous example was simplified to make a code comparison easy. To give you a more realistic view of what can be done with the two programming methods, here is an example of a 'Work with' type of application implemented as a LANSA function and as a Visual LANSA form.
Both applications are used for maintaining information in the sample PSLMST file. They use a logical view of the file which is keyed by employee surname. You can use them to view, edit and delete employee details.
The LANSA function was created using the FRMWRK1 template. It has a screen where you can limit the employees to be shown by entering a partial surname:
When you click OK, a Work with Employees screen is displayed. This screen shows a list of employees whose names match the partial name. You can view, modify or delete employee information by entering a number in the Opt field.
When you choose the Change option, a screen with input capable fields is displayed.
Similarly, selecting the Details and the Delete options brings up a screen showing the same information but with input protected fields.
Note that:
The Visual LANSA application consists of a single form. It performs the same actions as the LANSA function above. It has:
Note that:
An application like this can only be created because individual controls have their own event routines. Because the event routines are executed individually, the window can change dynamically according to user actions:
EVTROUTINE HANDLING(#Get.Click)
change #surname #partname
clr_list #list_1
SELECT FIELDS(#list_1) FROM_FILE(PSLMST2)
WITH_KEY(#SURNAME) GENERIC(*YES)
add_entry #list_1
ENDSELECT
ENDROUTINE
EVTROUTINE HANDLING(#List_1.ItemGotSelection)
FETCH FIELDS(#ALLFLDS) FROM_FILE(PSLMST) WITH_KEY(#EMPNO)
ENDROUTINE
EVTROUTINE HANDLING(#SAVE.CLICK)
UPDATE FIELDS(#ALLFLDS) IN_FILE(PSLMST) WITH_KEY(#EMPNO)
ENDROUTINE
EVTROUTINE HANDLING(#DELETE.CLICK)
DELETE FROM_FILE(PSLMST) WITH_KEY(#EMPNO)
ENDROUTINE
An application like this could not be implemented as a LANSA function because in a function the entire screen is processed as a whole.