Step 3 Review Filter Code

VLF Windows Application Development

Step 3. Review Filter Code

VFW040 – Snap in Real Filters

Although you can create simple filters using the Program Coding Assistant, you should understand how they are coded.

1.  Switch to the Visual LANSA editor, where the reusable part, iiiVFW04 is still open.

2.  Use the GoTo tab to select the uSelectData method routine. Double click on a routine on the Go To tab and the editor positions to that line.

     The filter notifies the Framework that an update is about to occur:

*  Indicate that Employees  instance list updating is about to start

Invoke Method(#avListManager.BeginListUpdate)

 

     The data is selected using a SELECT/ENDSELECT loop

*   Select appropriate instances of Employees
Select Fields(#XG_Ident) From_File(PSLMST2) With_Key(#XG_Keys) Nbr_Keys(*Compute) Generic(*yes)
* Set up the visual Identifier(s)
Change Field(#UF_VisID1) To(#EMPNO)
Change Field(#UF_VisID2) To(#SURNAME)
Use Builtin(BConcat) With_Args(#UF_VisID2 #GIVENAME) To_Get(#UF_VisID2)

 

     The Visual ID fields are set up with EMPNO and SURNAME + GIVENAME.

     Then the data is added to the instance list.

* Add instance details to the instance list

Invoke Method(#avListManager.AddtoList) Visualid1(#UF_VisID1) Visualid2(#UF_VisID2) Akey1(#EMPNO)

 

     Visualid1 will be shown in column one of the instance list and Visualid2 will be shown in column two. Akey1 is the key that uniquely identifies an employee. If it was a numeric value, NKey1 would be used.

     Finally, the Framework is notified that the instance list update is complete:

. . .

Endselect

*  Indicate that Employees  instance list updating is now complete

Invoke Method(#avListManager.EndListUpdate)

 

     Note: avListManager is a component which is part of the filter ancestor VF_AC007.

3.  For this step you need to ensure that your editor settings are showing advanced features. Use the Options menu to display the Settings dialog.

4.  Select the General settings and ensure that under Details, Show Advanced Features is selected.

5.  Select the Details tab in the editor, to display your component properties. Note that the Ancestor property is #VF_AC007. All filters must inherit this base class, which provides a pre-defined set of events, properties and methods.

6.  Select the Outline tab in the editor, to see the components you inherit from VF_AC007.

7.  Use the context menu on the component avListManager and select the Features option.

8.  Expand the methods and examine them. Double click on the AddtoList method and note that the Help tab contains help for this method.

9.  Close the component iiiVFW04. You may want to read the Windows Filter and Command Handler Anatomy in the Visual LANSA Framework Guide to learn more about how these components are structured.