How You Can Customize Error Messages
The top frame (main_control) of the Videos application defines a local error-handling procedure that it establishes as a data entry error handler. Because all frames in the application are called from the main_control frame, every frame in the application calls this handlerproc procedure implicitly whenever users type invalid values into entry fields.
The following code is the entire error-handling procedure defined in the main_control frame:
procedure handlerproc(
errorfield = entryfield;
errorframe = frameexec;
errormessage = varchar(2000)
not null) /* b yref() */=
begin
CurProcedure.beep();
if errorfield.DataType = 'date' then
errormessage = 'You must enter a valid
date in this field';
else
errormessage = '';
endif;
return EH_RESUME;
end;
Typing incorrect data in any entry field on any frame called by the main_control frame causes the monitor to beep.
When invalid data (such as an integer or Feb 31) is typed into a field with a date data type, the handlerproc procedure displays a pop-up message specific to date fields. Similar messages can be customized for other fields, but this procedure only beeps when invalid data is entered into a field other than a date field. No error message is displayed for other fields because the error message is changed to an empty string.
Because the handlerproc procedure returns EH_RESUME, control returns to the calling frame without searching for other data entry error handlers.
The following code from the main_control frame declares handlerproc as a procedure and establishes it to handle data entry errors:
initialize =
declare
handlerproc = procedure returning integer
not null; /* local procedure */
enddeclare
begin
CurFrame.DataEntryErrorHandler =
CurFrame.Scope.GetProcHandle
(name = 'handlerproc');
...
end;