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.
The Visual LANSA application consists of a single form. It performs the same actions as the LANSA function above. It has:
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:
change #surname #partname
SELECT FIELDS(#list_1) FROM_FILE(PSLMST2)
FETCH FIELDS(#ALLFLDS) FROM_FILE(PSLMST) WITH_KEY(#EMPNO)
UPDATE FIELDS(#ALLFLDS) IN_FILE(PSLMST) WITH_KEY(#EMPNO)
DELETE FROM_FILE(PSLMST) WITH_KEY(#EMPNO)
An application like this could not be implemented as a LANSA function because in a function the entire screen is processed as a whole.