trigger clear

Trigger that reacts to the user's request to start over with a clean form.

Declaration: trigger clear
Applies to: Form
Activation: Activated by the ^CLEAR structure editor function.
Default behavior: None
Behavior upon completion: None

Description

The default ProcScript provided for this trigger has the effect of dropping all the data currently in the component; any data that has been entered or retrieved is removed from the component. This does not remove the data from the database, but any information entered by the user that has not been stored is lost.

Using clear to drop all data in a form also implicitly drops all outstanding data validation checks, which provides a handy mechanism for recovering from edit session situations that have gotten out of control.

The default ProcScript provided by Uniface for this trigger contains the ProcScript statement clear. Any non-default ProcScript entered in this trigger by the developer must contain the ProcScript statement clear if the intended functionality of this trigger is desired. To clear specific entities rather than the entire form, use the clear/e statement. It is useful to check for modifications before clearing the form.

Save As Functionality

The clear trigger is sometimes used to save an existing database occurrence as a new occurrence with a new primary key. The release statement releases the controls on primary key fields and marks retrieved data as being entered by the user.

Save As Functionality

In the following example, the ProcScript in the clear trigger uses the $instancedb function to test if the data in the form has come from the database; if so, the release statement marks the data as having been entered by the user and releases the controls on the primary key fields. If the data is marked as having been entered by the user and not coming from the database, the data is cleared. This construction allows a user to clear the form in two passes: the first pass provides Save As functionality for a database occurrence, the second pass clears the form.

trigger clear
if ($instancedb = 1)
   release 
   message "Controls released; data available as default for new input"
else
   clear
endif
end ; clear

Related Topics