Consultor Eletrônico



Kbase P184697: 4GL/ABL: How to force a character client application user input into a fill-in to be in the format
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   25/03/2011
Status: Unverified

GOAL:

4GL/ABL: How to force a character client application user input into a fill-in to be in the format "HH:MM AM" or "HH:MM PM" ?

GOAL:

How to validate a TTY application user input into a fill-in to be valid for the format "HH:MM AM" or "HH:MM PM" where HH is from 00 through 12?

GOAL:

How to control user input of time with hours, min, AM or PM and restrict that input to the "HH:MM AM" or "HH:MM PM" format?

FACT(s) (Environment):

All Supported Operating Systems
Progress 9.x
OpenEdge 10.x

FIX:

For a character (TTY) application, use the ANY-PRINTABLE event trigger to both restrict user input to only valid letters or digits. For example, the following procedure, forces the user input into a fill-in to be in the format "HH:MM AM" or "HH:MM PM" and validates that each digit or letter input is valid:
DEFINE VARIABLE cFillDate AS CHARACTER FORMAT "99:99: !M" NO-UNDO.
DEFINE FRAME fFillDate
cFillDate AT ROW 1 COL 10 COLON-ALIGNED
WITH NO-BOX SIDE-LABELS CENTERED ROW 10.
ON ANY-PRINTABLE OF cFillDate IN FRAME fFillDate
DO:
DEFINE VARIABLE iCursorPosition AS INTEGER NO-UNDO.
DEFINE VARIABLE cFirstCharacter AS CHARACTER NO-UNDO.
DEFINE VARIABLE cSecondCharacter AS CHARACTER NO-UNDO.
DEFINE VARIABLE cThirdCharacter AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFifthCharacter AS CHARACTER NO-UNDO.
DEFINE VARIABLE cSixthCharacter AS CHARACTER NO-UNDO.
ASSIGN
iCursorPosition = SELF:CURSOR-OFFSET.
CASE iCursorPosition:
WHEN 1 THEN
DO:
cFirstCharacter = CHR(LASTKEY).
IF INDEX ( '0,1', cFirstCharacter) = 0 THEN RETURN NO-APPLY.
END.
WHEN 2 THEN
DO:
cSecondCharacter = CHR(LASTKEY).
IF cFirstCharacter = '1' AND INDEX ( '0,1,2', cSecondCharacter) = 0 THEN RETURN NO-APPLY.
IF cFirstCharacter = '0' AND INDEX ( '0,1,2,3,4,5,6,7,8,9', cSecondCharacter) = 0 THEN RETURN NO-APPLY.
END.
WHEN 3 THEN
DO:
cThirdCharacter = CHR(LASTKEY).
IF INDEX ( '0,1,2,3,4,5', cThirdCharacter) = 0 THEN RETURN NO-APPLY.
END.
WHEN 5 THEN
DO:
cFifthCharacter = CHR(LASTKEY).
IF INDEX ( '0,1,2,3,4,5,6,7,8,9', cFifthCharacter) = 0 THEN RETURN NO-APPLY.
END.
WHEN 6 THEN
DO:
cSixthCharacter = CHR(LASTKEY).
IF INDEX ( 'A,P,a,p', cSixthCharacter) = 0 T.HEN RETURN NO-APPLY.
ELSE SELF:SCREEN-VALUE = CAPS(SELF:SCREEN-VALUE).
END.
END CASE.
END.

DISPLAY cFillDate WITH FRAME fFillDate.
ENABLE ALL WITH FRAME fFillDate.
WAIT-FOR CLOSE OF THIS-PROCEDURE..