DEFAULT attribute

The DEFAULT attribute assigns a default value to a field during data entry.

Syntax

DEFAULT = value
  1. value can be any literal expression supported by the form compiler, as long as it matches the form field type.
  2. value can be TODAY to specify the current system date as default.
  3. value can be CURRENT to specify the current system datetime as default.

Usage

The literal constant specified after 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.

The effect of the DEFAULT attribute depends on the WITHOUT DEFAULTS configuration option of the dialog using the form:

With the INPUT statement, form default values have are ignored when using the WITHOUT DEFAULTS option. 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 ARRAY statement, the form default values are always used for new rows inserted by the user. With INPUT ARRAY, the WITHOUT DEFAULTS option indicates if the existing program array elements have to be used.

Defaults values can also be specified in the database schema file, for form fields defined with database column reference.

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 assigned to the same field, the REQUIRED attribute is ignored.

If you do not use the WITHOUT NULL INPUT option in the DATABASE section of a form, all fields default to null values unless you have specified a DEFAULT attribute.

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;