DEFAULT attribute
The DEFAULT attribute defines a default value to a field during data
entry.
Syntax
DEFAULT = value
- value can be any literal expression supported by the form compiler, as long as it matches the form field type.
- value can be
TODAYto specify the current system date as default. - value can be
CURRENTto specify the current system datetime as default.
Usage
The DEFAULT attribute defines a default value for the form field.
The literal constant specified as default value must match the form field type. For example, when defining a numeric field, use a numeric decimal constant, for character string fields, use a double-quoted character literal.
DEFAULT attribute depends on the WITHOUT
DEFAULTS configuration option of the dialog using the form:- With the
INPUTstatement, form default values are ignored when using theWITHOUT DEFAULTSoption. With this option, the runtime system displays the values in the program variables to the screen. Otherwise, the form default values will be displayed when the dialog starts. - With the
INPUT ARRAYstatement, theWITHOUT DEFAULTSoption indicates if the existing program array elements have to be used. The form default values are always used for new rows inserted by the user. Default values can be set by program in theBEFORE INSERTblock.
Default values can also be specified in the database schema file, for form fields defined with database column reference.
When not using WITHOUT NULL INPUT option in the DATABASE
section of a form, all fields default to null values unless a DEFAULT attribute
is specified in the ATTRIBUTES section.
If the field is FORMONLY, you must also specify a data type when you assign
the DEFAULT attribute to a field.
If both the DEFAULT attribute and the REQUIRED attribute are
defined for a field, the REQUIRED attribute is ignored.
Note that DATETIME and INTERVAL literals are not supported
in the DEFAULT attribute.
Example
EDIT f001 = order.orderdate, DEFAULT = TODAY;
EDIT f012 = FORMONLY.discount TYPE DECIMAL(5,2), DEFAULT=0.10;