Step 2 Use a SELECTLIST Command

Visual LANSA

Step 2. Use a SELECTLIST Command

FRM075 - Using a Working List

In this step you will add another copy of the iiiTOTSAL field to the form and a push button. Clicking the push button will read through the List View EMPLOYS using a SELECTLIST/ENDSELECT command and total the currently selected entries into the new total field.

1.  Drop a Group Box onto the right hand side of your form. Resize it and change its Caption property to Compute Selected.

2.  Drag and drop field iiiTOTSAL into the group box. Note that it will be renamed to iiiTOTSAL_1. Changes its LabelPosition to Top.

3.  Drag and drop a push button into the group box.

     Change its Name to COMPUTE and Caption to Calc. Total Salary.

     Create a COMPUTE.Click event routine.

     Your form should look like the following:

4.  In this step you will complete the COMPUTE click event logic.

a.  SELECTLIST/ENDSELECT will read all entries in a list component.

b.  The selected entries can be identified by using their CurrentItem property. Entries in a list are themselves a component. CurrentItem has a Selected property (true or false).

c.  Use F2 Feature help on a component to discover all its events, properties and methods and the help associated with each of these.

d.  Double-click PRIM_LVIT to see the events, properties and methods of a list item:

e.  Expand the list item properties and choose the Selected property to see its description:

     The following code will accumulate SALARY into iiiTOTSAL for selected items:

Evtroutine Handling(#COMPUTE.Click)

#iiitotsal_1 := *zeroes
Selectlist
If (#EMPLOYS.currentItem.selected = true)

#IIITOTSAL_1 += #salary

Endif

Endselect

Endroutine

 

5.  Compile and test your form: