4D v16.3

On Host Database Event database method

Home

 
4D v16.3
On Host Database Event database method

On Host Database Event database method 


 

$1 -> On Host Database Event database method 
Parameter Type   Description
$1  Longint in Event code

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:

Constant Type Value Comment
On after host database exit Longint 4 The On Exit database method of the host database has just finished running
On after host database startup Longint 2 The On Startup database method of the host database just finished running
On before host database exit Longint 3 The 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 startup Longint 1 The 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
 C_LONGINT($1)
 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

 
PROPERTIES 

Product: 4D
Theme: Database Methods

 
HISTORY 

Created: 4D v14

 
ARTICLE USAGE

4D Language Reference ( 4D v16)
4D Language Reference ( 4D v16.1)
4D Language Reference ( 4D v16.2)
4D Language Reference ( 4D v16.3)