Consultor Eletrônico



Kbase 13930: Date Fields and special formats -- How to clear ( f8 )
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/05/1998
Date Fields and special formats -- How to clear ( f8 )

Error 80 (the month of a date must be between 1 and 12) is often the
result of a user data entry error when updating a DATE field.

A data field of type DATE will, by default, be initialized to the
unknown value (?). When entering data, the user can <TAB> or <ENTER>
through the field *only* if no value has been entered. Once the user
begins entering data, the initial value is lost and the field
validation will occur, requiring a valid date format to be entered,

To correct a data entry error, the user can enter ? which is a valid
date value and can then <TAB> or <ENTER> past the field without the
error.

It is also true that character fields that have special formats
must also be cleared with the ? unknown value. This, again, is the
result of the fact that once the initial value is lost, validation
will occur. An example of this may be a social security number
that is implemented as a character field in the following way:

define var social-security as char format 999-99-9999.

Initially, you can tab in and out of the social-security field
even though it is blank; however, once a value has been typed in
the initial value is lost and validation will occur when you try to
leave the field EVEN IF YOU HAVE ATTEMPTED TO CLEAR IT. You will
get the following validation error:

Character at position 8 must be digit. (630)

As with the date field, typing the unknown character (?) will allow
you to leave the social-security field and will also assign the
the unknown value (?) to the field.
Unlike the date field, the unknown value (?) will also be DISPLAYED
in specially formatted character fields. This is different than the
date field where a BLANK date is displayed.


In all versions of Progress it is recommended that you continue to
use the ? to clear dates and specially formatted character fields even
though you will see the '?' in the character fields. This method
will still allow you to leave the field and when you re-enter it
and type in valid data for that field, the formatting characters will
re-appear (such as the '/' for date and the '-' for social-security).

In version 8, you may be able to code around the social-security
issue because the MODIFIED attribute of a field was made writable
by 4GL programmers in this version. In other words, when you first
lose the initial state by typing data into the fields, the MODIFIED
attribute for that field is set to TRUE (this is what causes
validation to occur). You could implement code that will change
the MODIFIED attribute to FALSE on the F8 trigger. A small example
is provided here but please note that this is only a sample and there
may be cases that will not work. It is up to you, the 4GL programmer,
to account for all cases.

def var d as date format 99/99/9999.
def var da as char format "99-999-9999" init ?.
def frame x d da.
DEF VAR ok2go AS LOG INIT FALSE.
ON F8 OF da IN FRAME x
ok2go = TRUE.

ON TAB, CTRL-U, SHIFT-TAB OF da IN FRAME x DO:
IF ok2go
THEN ASSIGN da:MODIFIED = FALSE.
ok2go = FALSE.
END.
enable d da with frame x.
wait-for go of frame x.


This example will allow you to use F8 to clear the field 'da' which is
of social security format and then to leave the field. With this
code you will not have to type in the unknown value ? and therefore
will not end up with `?` as the text displaying in your field.

Progress Software Technical Support Note # 13930