# Views System

Logic Procedures |

The Views System allows you to specify logic to be performed at various levels in the definition and/or execution of a view. You can access and input the initialization, closing, and execution logic directly via the Logic Procedures panel in Data Source Maintenance and View Maintenance. You can also supply a Logic Object to perform these procedures using the methods OnLoad( ), OnClose( ), and OnExecute( ).

Logic procedures can be invoked at three levels:

| Initialization Logic | Can be used to set up environment variables, parameters, pathnames, functions, and other global information that may be needed by the Views System. For example, this might be useful for establishing a working environment for accessing views through the PxPlus SQL ODBC Driver.
| Close Logic | Opportunity to reset any environment settings that were established during the initialization level.
| Execution Logic | Allows for final adjustments of a definition after opening a view but before data retrieval. For example, this might be useful for suppressing certain columns based on user security levels.

The following list outlines the order in which logic procedures are applied:

| 1. | General Initialization | When initially entering the Views System
| 2. | General Execution | Prior to retrieving/displaying data
| 3. | View Initialization | When a view is opened via 'Open( ) method
| 4. | Data Source Initialization | When a data source handler is established
| 5. | Data Source Close | When a data source handler is dropped
| 6. | View Close | When a view is closed via 'Close( ) method
| 7. | General Close | Prior to exiting the Views System

Logic Procedures Panel

General Logic procedures can be accessed from the Data Source Maintenance main panel. Similar panels, but without reference to Execution Logic, can be accessed during the definition of data sources and views.

## Logic Object

Logic procedures can also be set using the methods SetInitLogic( ), SetExecutionLogic( ) and SetCloseLogic( ). If an Object Name is specified under Logic Object, the object created by the user must supply the following methods:

| OnLoad(vctl) | Containing initialization logic. OnLoad( ) will be passed an argument with the ViewCtl object identifier.
| OnClose( ) | Containing closing logic.

If the object is supplying logic at the general level, it must also have:

| OnExecute( ) | Contains logic to be invoked prior to executing a view.

The methods can be referenced when defining data source elements by using special object identifiers when invoking a method in the Expression column of the element grid. If a general view object is specified, its methods can be accessed using the object identifier _view'. Methods defined in the object for a specific view can be accessed using the object identifier _v', and the object identifier _ds' can be used to access methods from the object specified for a data source.

#### Note:
Column methods will always be executed at the data source level; therefore, you cannot combine field references from multiple data sources in their logic.