views(
views(
OPTION
,
VALUE
)

The views( function lists views in open databases.

Parameters

This function has two parameters:

option – option name. This parameter is optional (there can be zero or more option/value pairs). Possible option names are: `database`, `field`, `sort` and `libraries`.

value – value corresponding with the option name.

Description

This function lists views in open databases. The list is a carriage return separated text array, one line per view. Each line is divided into multiple fields separated by tabs. At a minimum, the first three fields list the view name, database name, and type of view (`DATASHEET`, `FORM` or `PROCEDURE`). You can also specify that additional fields be included, see below.

#### DATABASE

The views( function normally lists the views for all open databases. Use the database option if you only want to list the views for a single database. This example lists the views in the Checkbook database.

    views("database","Checkbook")

The views( function normally does not list views for library databases. This example shows how to include library databases in the list.

    views("libraries",true())

#### VIEWTYPE

The views( function normally lists all types of views. Use the viewtype option to restrict the output to certain types of views: procedures, forms, or data sheet. (The data sheet view includes field names and automatic formulas and code associated with fields.) This example lists all procedures in the General Ledger database:

    views("database","General Ledger","viewtype","procedures")

Note: Only the first letter of the viewtype option is considered, so you could use f instead of forms or p instead of procedures.)

#### SORT

The views( function normally lists the views alphabetically. If you want to list them in the order they have most recently been opened, use the `"sort","recent"` option:

    views("sort","recent")

This example shows how to explicitly sort alphabetically:

    views("sort","alphabetic")

This example shows how to disable sorting, so that views are listed in the actual order they appear in the database (for example, this is the order that procedures will appear in the Action menu).

    views("sort","none")

Note: Only the first letter is required for the sort option, so the three examples above could be written as:

    views("sort","r")
    views("sort","a")
    views("sort","n")

#### FIELD

Use the fields option to add additional fields to the output. You can control which fields are added, and in what order. The available fields are `"source"`, `"error"`, `"notes"`, `"tag"`, and `"recent"`. Here is an example that includes any error messages and source code for each view.

    views("sort","recent","field","error","field","source")

The `"source"` field includes all source code associated with the view. For procedure views this means the source code of the procedure. For form views this includes all formulas, procedures, and field names that are part of objects within the form. In any case, the source code is “smushed” together. All line breaks are converted to spaces, and for forms all of the various source code items are compacted together. The purpose of the source code field is to allow searching for which views reference a particular field, variable name, function, etc. If you want to recover individual source code elements you’ll need to use other tools, for example the objectinfo( function.

The `"error"` field will contain the error message associated with a procedure, if any. It allows you to quickly identify which procedures have syntax errors.

The `"recent"` field will contain the number of seconds since this view was last the frontmost window.

See Also

- dbinfo( -- gets information about a database: what forms it contains, what fields, what flash art pictures, etc.
- listwindows( -- builds a text array containing a list of all the open windows associated with a particular file.

History

Version | Status | Notes
10.0 | New | New in this version