Progress
Programming
Handbook


Setting Up Dynamic Field-level Widgets

When setting up dynamic field-level widgets, it helps to keep these points in mind:

The following procedure creates a dynamic fill-in with the INTEGER data type when you choose the Customer Number button. You can then enter a value according to the “>>>>9" format. The entered integer value is stored as a character string in the screen buffer. Pressing RETURN displays this value in the message area. Choosing the Delete Field button deletes the fill-in, removing it from the display:

p-dynfl1.p
DEFINE BUTTON bCustNumber LABEL "Customer Number".
DEFINE BUTTON bDelete LABEL "Delete Field".
DEFINE VARIABLE fCustHandle AS WIDGET-HANDLE.
DEFINE VARIABLE lCustHandle AS WIDGET-HANDLE.
DEFINE FRAME CustFrame
  SKIP(3)
  SPACE (1) bCustNumber bDelete
  WITH SIZE 40 BY 5 SIDE-LABELS.

ON CHOOSE OF bCustNumber IN FRAME CustFrame
DO:
  IF fCustHandle <> ? THEN
  DO:
    MESSAGE bCustNumber:LABEL "field already exists.".
    RETURN.
  END.
  CREATE TEXT lCustHandle
    ASSIGN
    FRAME = FRAME CustFrame:HANDLE
    DATA-TYPE = "CHARACTER"
    FORMAT = "x(16)"
    SCREEN-VALUE = "Customer Number:"
    ROW = 2
    COLUMN = 2
  .
  CREATE FILL-IN fCustHandle
    ASSIGN
      FRAME = FRAME CustFrame:HANDLE
      DATA-TYPE = "INTEGER"
      FORMAT = ">>>>9"
      SIDE-LABEL-HANDLE = lCustHandle
      ROW = 2
      COLUMN = lCustHandle:COLUMN + lCustHandle:WIDTH-CHARS + 1
      SENSITIVE = TRUE
      VISIBLE = TRUE
    TRIGGERS:
      ON RETURN PERSISTENT RUN SetFieldTrig.
    END TRIGGERS
  .
END. 
ON CHOOSE OF bDelete IN FRAME CustFrame
DO:
  IF fCustHandle <> ? THEN
  DO:
    DELETE WIDGET fCustHandle.
    fCustHandle = ?.
    DELETE WIDGET lCustHandle.
  END.
END.

ENABLE ALL WITH FRAME CustFrame.
WAIT-FOR GO OF FRAME CustFrame.

PROCEDURE SetFieldTrig:
  MESSAGE "You entered" lCustHandle:SCREEN-VALUE
           fCustHandle:SCREEN-VALUE.
END PROCEDURE. 


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095