Saltar al contenido principal
Versión: Siguiente

On Host Database Event database method

$1 -> On Host Database Event database method

ParameterTypeDescription
$1IntegerEvent code

Description

The On Host Database Event database method allows 4D components to execute code when the host database is opened and closed.

Note: For security reasons, in order to be able to call this database method, you must explicitly allow its execution in the host database. For more information about this point, refer to the Design Reference manual.

The On Host Database Event database method is executed automatically only in databases used as components of host databases (when it is authorized in the Settings of the host database). It is called when events related to the opening and closing of the host database occur.

To process an event, you must test the value of the $1 parameter inside the method, and compare it with one of the following constants, available in the "Database Events" theme:

ConstantTypeValueComment
On after host database exitInteger4The On Exit database method of the host database has just finished running
On after host database startupInteger2The On Startup database method of the host database just finished running
On before host database exitInteger3The host database is closing. The On Exit database method of the host database has not yet been called.
The On Exit database method of the host database is not called while the On Host Database Event database method of the component is running
On before host database startupInteger1The host database has just been started. The On Startup database method method of the host database has not yet been called.
The On Startup database method of the host database is not called while the On Host Database Event database method of the component is running

This allows 4D components to load and save preferences or user states related to the operation of the host database.

Example

Example of typical structure of an On Host Database Event database method:

  // On Host Database Event database method
 var $1 : Integer
 Case of
    :($1=On before host database startup)
  // put code here that you want to execute before the "On Startup" database method
  // of the host database
    :($1=On after host database startup)
  // put code here that you want to execute after the "On Startup"
  // database method of the host database
    :($1=On before host database exit)
  // put code here that you want to execute before the "On Exit"
  // database method of the host database
    :($1=On after host database exit)
  // put code here that you want to execute after the "On Exit"
  // database method of the host database
 End case