Go to the first, previous, next, last section, table of contents.


Filter

Filters can be used to hide records. This chapter describes what types of filters are available and how to use them.

MUIbase knows two types of filters, record filters and reference filters.

Record filter

A record filter can be installed into a table to filter out records that are not of interest to you. Records that are filtered out are excluded in the table mask and thus the user can't see or browse to them.

Filter expression

A filter is defined by specifying a boolean expression that may contain calls to MUIbase programming functions. For each record of the table the filter is specified for, this expression is evaluated. If it returns NIL then the record is filtered out, otherwise it is included in the table mask.

Each table can have its own filter expression.

Changing filters

To change the filter of the current table select menu item `Table - Change filter'. This will open a window containing

After you are done with the specification of the filter expression click on the `Ok' button to leave the window. The entered expression is now compiled and, if successful, the expression is evaluated for all records. Those records for which the boolean expression doesn't hold are then discarded in the table mask.

In case the expression doesn't compile you will get an error message displayed in the window title bar.

A filter can be turned on and off by clicking on the `F' button in the table's panel (if it is installed), or by pressing the F key when the panel is the active object. After you have specified a filter expression for a table the filter for this table is turned on automatically.

If you (re-)activate a filter then all records of the table are checked whether they match the filter or not.

If a filter is currently active and you change a (filter relevant) attribute in a record of this table then the match-filter state of this record is not recomputed and stays unchanged.

If you allocate a new record in a table with an activated filter then there is no check if the new record matches the filter and the new record has its match-filter state set to TRUE.

Filter examples

Here are some examples for valid filter expressions:

Please note that MUIbase' programming language uses a lisp-like syntax. For more information about the programming language, see section Programming MUIbase.

Reference filter

Reference attributes can also have a filter behavior. This is useful e.g. for building a hierarchy of tables (like it is hard-wired in AmigaBase). As an example see the project `Albums'.

If the filter of a reference attribute is turned on then the following features are activated:

  1. The user can only access records in the attribute's table that have the reference set to the current record of the referenced table.
  2. If the referenced table changes its current record then also a new current record is searched and set for the attribute's table.
  3. When allocating a new record the reference is automatically set to the current record of the referenced table.

Note: Cascading delete (like it is automatically done in AmigaBase) has to be implemented by the user himself (by using a delete trigger function).

Do not use the reference filter on cyclic graphs, e.g. self-referencing tables. It doesn't make sense and will only confuse the user.


Go to the first, previous, next, last section, table of contents.