This is one of a hopefully continuing series of periodic posts highlighting recently added routines that might be useful (as-is or as examples) that might otherwise go without notice buried in the treasure chest of the SOSLIB and EXLIB repositories.In this case, the subject is XTREE-based filtering. There are several ways in which XTREE and data-filtering might go together:
1) Using XTREE as a means of displaying the result set. (This is an obvious use for XTREE and doesn't require any special features or examples.)
2) Using XTREE as a means of inputting the filter criteria (i.e. as a somewhat more user-friendly alternative to something like SQL). A new SOSLIB module,
FNXFLTR.BSI contains a few handy functions for implementing such a dialog. One, Fn'XFLTR'Dlg() handles the UI, creating the dialog and prompting for the selection info. (You configure it by setting up an array describing the fields available for selection.) Another, Fn'XFLTR'Field() applies the captured selection criteria to a single field to determine if it satisfies the crieria. (The app loops through the available records, passing the relevant fields to this routine.) For the SQL environment, another routine, Fn'XFLTR'Gen'SQL'Query$(), can be used to convert the criteria entered by the user via Fn'XFLTR'Dlg() into an SQL query string.
3) Using the Coldef LoadOptions=NoRowIf! command (new as of 6.5.1627.0) to tell XTREE which records from the array to load into the tree, i.e. to convey the filtering results to XTREE without having to build a new array. An EXLIB sample program,
TSTXFLTR2.BP , illustrates how it might be used.
Combining the above we get something like this: