PreviousNextIndex

DEFINE FRAME statement

Defines and creates a frame or dialog box that is created at compile time for use in one or more procedures, or within a single class.

Syntax

DEFINE { [ [ NEW ] SHARED ] | [ PRIVATE ] } FRAME frame 
  [ form-item ... ] 
  [{ HEADER | BACKGROUND } head-item ... ] 
  { [ frame-phrase ] } 

DEFINE { [ [ NEW ] SHARED ] | [ PRIVATE ] } FRAME frame 
  record [ EXCEPT field ... ] 
  { [ frame-phrase ] } 

NEW SHARED FRAME frame
SHARED FRAME frame
[ PRIVATE ] FRAME frame
FRAME frame
form-item
field
format-phrase
constant
at-phrase
TO n
BGCOLOR expression
DCOLOR expression
FGCOLOR expression
FONT expression
PFCOLOR expression
VIEW-AS TEXT
WIDGET-ID id-number
SPACE ( n )
SKIP ( n )
record
EXCEPT field . . .
HEADER
BACKGROUND
head-item
frame-phrase
Examples

The following example, r-deffrm.p, uses the DEFINE FRAME statement to set up the format of a frame. It then scopes that frame to a FOR EACH block.

r-deffrm.p
DEFINE VARIABLE bal-avail NO-UNDO LIKE Customer.Balance 
  COLUMN-LABEL "Available!Credit" NO-UNDO. 
DEFINE FRAME cust-bal  
  Customer.CustNum 
  Customer.Name FORMAT "X(20)" 
  Customer.CreditLimit LABEL "Limit" 
  Customer.Balance 
  bal-avail 
  WITH CENTERED ROW 3 TITLE "Available Customer Credit" USE-TEXT. 
  
FOR EACH Customer NO-LOCK WITH FRAME cust-bal: 
  DISPLAY  
    Customer.CustNum 
    Customer.Name 
    Customer.CreditLimit 
    Customer.Balance 
    Customer.CreditLimit - Customer.Balance @ bal-avail. 
END. 

The following example defines three frames. The cust-info frame is scoped to the trigger for the b_next button where it is first referenced. Similarly, the cust-dtl frame is scoped to the b_dtl trigger. The butt-frame frame is scoped to the outer procedure block.

r-dffrm1.p
DEFINE BUTTON b_dtl  LABEL "Detail". 
DEFINE BUTTON b_next LABEL "Next". 
DEFINE BUTTON b_quit LABEL "Quit" AUTO-ENDKEY. 
DEFINE FRAME cust-info  
  Customer.CustNum 
  Customer.Name FORMAT "X(20)" 
  Customer.Phone 
  WITH CENTERED ROW 4. 
DEFINE FRAME cust-dtl 
  Customer EXCEPT Customer.CustNum Customer.Name Customer.Phone 
  WITH CENTERED SIDE-LABELS ROW 9. 
DEFINE FRAME butt-frame 
  b_dtl b_next b_quit 
  WITH ROW 1. 
   
ON CHOOSE OF b_dtl 
  DISPLAY Customer EXCEPT Customer.CustNum Customer.Name Customer.Phone 
    WITH FRAME cust-dtl. 
ON CHOOSE OF b_next DO: 
  HIDE FRAME cust-dtl. 
  FIND NEXT Customer NO-LOCK NO-ERROR. 
  IF NOT AVAILABLE Customer THEN 
    FIND LAST Customer NO-LOCK. 
  DISPLAY Customer.CustNum Customer.Name Customer.Phone 
    WITH FRAME cust-info. 
END. 
ENABLE ALL WITH FRAME butt-frame. 
APPLY "CHOOSE" TO b_next IN FRAME butt-frame. 
WAIT-FOR CHOOSE OF b_quit. 

The following example uses a set of thin rectangles as lines to create graphic columns within a frame background:

r-bkgrnd.p
DEFINE VARIABLE item-tot AS DECIMAL NO-UNDO LABEL "Value". 
DEFINE RECTANGLE vline1 SIZE .4 BY 5 EDGE-PIXELS 2. 
DEFINE RECTANGLE vline2 LIKE vline1. 
DEFINE RECTANGLE vline3 LIKE vline1. 
DEFINE RECTANGLE vline4 LIKE vline1. 
DEFINE RECTANGLE vline5 LIKE vline1. 
DEFINE RECTANGLE vline6 LIKE vline1. 
DEFINE RECTANGLE hline SIZE 78 BY .1 EDGE-PIXELS 2. 
DEFINE FRAME item-info 
  Item.ItemNum 
  Item.ItemName 
  Item.OnHand 
  Item.ReOrder 
  Item.OnOrder 
  Item.Price 
  Item-tot 
  BACKGROUND SKIP(1) hline 
    vline1 AT 9 
    vline2 AT 25 
    vline3 AT 33 
    vline4 AT 42 
    vline5 AT 51 
    vline6 AT 65 
  WITH TITLE "Inventory Current Value" CENTERED USE-TEXT 5 DOWN. 
   
FOR EACH Item NO-LOCK WITH FRAME item-info: 
  DISPLAY  
    Item.ItemNum 
    Item.ItemName 
    Item.OnHand 
    Item.ReOrder 
    Item.OnOrder 
    Item.Price 
    Item.OnHand * Item.Price @ item-tot. 

The following procedure defines the shared frame cust-frame. It also defines a shared variable and a shared buffer. For each Customer whose Customer number is less than 20, the procedure displays Customer information in the cust-frame. The format for the cust-frame is defined in the r-shrfrm.i include file.

r-shrfrm.p
DEFINE NEW SHARED FRAME cust-frame. 
DEFINE NEW SHARED VARIABLE csz AS CHARACTER FORMAT "x(29)". 
DEFINE NEW SHARED BUFFER xcust FOR Customer. 
FOR EACH xcust WHERE xcust.CustNum <=20: 
  {r-shrfrm.i}    /* shared frame layout */ 
  DISPLAY xcust.Name xcust.Phone xcust.Address xcust.SalesRep 
    xcust.City + ", " + xcust.State + " " + xcust.PostalCode @ csz 
    xcust.CreditLimit WITH FRAME cust-frame. 
  RUN r-updord.p. /* Update Customer’s orders */ 
END. 

Following is the r-shrfrm.i include file:

r-shrfrm.i
FORM 
  xcust.Name COLON 10 
  xcust.Phone COLON 55 
  xcust.Address COLON 1 
  xcust.SalesRep COLON 55 
  csz NO-LABEL COLON 10 
  xcust.CreditLimit COLON 55 SKIP(2) 
  Order.OrderNum COLON 10 Order.OrderDate COLON 30 
  Order.ShipDate COLON 30 
  Order.PromiseDate COLON 30 
  WITH SIDE-LABELS 1 DOWN CENTERED ROW 5 
  TITLE "Customer/Order Form" FRAME cust-frame. 

After the r-shrfrm.p procedure displays the Customer information, it calls the r-updord.p procedure.

The r-updord.p procedure defines the variable, frame, and buffer that were originally defined in the r-shrfrm.p procedure. However, in this second reference to the items, the keyword NEW is omitted. The r-updord.p procedure displays, and lets you update, the Order information for the Customer displayed in the cust-frame. The Order information is displayed in the same frame.

r-updord.p
DEFINE SHARED FRAME cust-frame. 
DEFINE SHARED VARIABLE csz AS CHARACTER NO-UNDO FORMAT "x(29)". 
DEFINE SHARED BUFFER xcust FOR Customer. 
FOR EACH Order OF xcust: 
  {r-shrfrm.i }  /* shared frame layout */ 
  DISPLAY Order.OrderNum WITH FRAME cust-frame. 
  UPDATE Order.OrderDate Order.ShipDate Order.PromiseDate 
    WITH FRAME cust-frame. 
END. 

The following example, r-fof1.p, creates a dialog box to display Customer information from a query. The dialog box contains three child frames to display Customer contact information (FRAME cont-fr), Customer account information (FRAME acct-fr), and control buttons for moving through the query results list (FRAME ctrl-fr).

r-fof1.p 
DEFINE QUERY custq FOR Customer. 
DEFINE BUTTON bprev LABEL "<". 
DEFINE BUTTON bnext LABEL ">". 
DEFINE FRAME cust-fr SKIP(.5) 
  SPACE(8) Customer.Name Customer.CustNum Customer.SalesRep 
  Customer.Comments AT COLUMN 6 ROW 13.5 
  WITH SIDE-LABELS TITLE "Customer Data" SIZE 80 BY 15 VIEW-AS DIALOG-BOX. 
DEFINE FRAME cont-fr SKIP(.5) 
  Customer.Address COLON 17 SKIP 
  Customer.Address2 COLON 17 SKIP 
  Customer.City COLON 17 SKIP 
  Customer.State COLON 17 SKIP  
  Customer.PostalCode COLON 17 SKIP 
  Customer.Country COLON 17 SKIP 
  Customer.Contact COLON 17 SKIP  
  Customer.Phone COLON 17 
  WITH SIDE-LABELS TITLE "Contact Informaion" SIZE 40 BY 10 AT COLUMN 1 ROW 3. 
DEFINE FRAME ctrl-fr SKIP(.12) 
  SPACE(4) bprev bnext 
  WITH TITLE "PREVIOUS/NEXT" SIZE 15 BY 2 AT COLUMN 53 ROW 10.5. 
DEFINE FRAME acct-fr SKIP(.5) 
  Customer.Balance COLON 15 SKIP  
  Customer.CreditLimit COLON 15 SKIP 
  Customer.Discount COLON 15 SKIP  
  Customer.Terms COLON 15 
  WITH SIDE-LABELS TITLE "Account Information" 
  SIZE 38.85 BY 6 AT COLUMN 41 ROW 3. 
ON CHOOSE OF bnext DO: 
  GET NEXT custq. 
  IF NOT AVAILABLE Customer THEN GET FIRST custq. 
  RUN display-proc IN THIS-PROCEDURE. 
END. 
ON CHOOSE OF bprev DO: 
  GET PREV custq. 
  IF NOT AVAILABLE Customer THEN GET LAST custq. 
  RUN display-proc IN THIS-PROCEDURE. 
END. 
FRAME cont-fr:FRAME = FRAME cust-fr:HANDLE. 
FRAME acct-fr:FRAME = FRAME cust-fr:HANDLE. 
FRAME ctrl-fr:FRAME = FRAME cust-fr:HANDLE. 
OPEN QUERY custq PRESELECT EACH Customer BY Customer.Name. 
GET FIRST custq. 
RUN display-proc IN THIS-PROCEDURE. 
ENABLE ALL WITH FRAME ctrl-fr. 
WAIT-FOR WINDOW-CLOSE OF FRAME cust-fr. 
PROCEDURE display-proc: 
  DISPLAY  
    Customer.Name Customer.CustNum Customer.SalesRep 
    Customer.Comments WITH FRAME cust-fr. 
  DISPLAY 
    Customer.Address Customer.Address2 Customer.City Customer.State 
    Customer.PostalCode Customer.Country Customer.Contact Customer.Phone 
    WITH FRAME cont-fr. 
  DISPLAY  
    Customer.Balance Customer.CreditLimit Customer.Discount Customer.Terms 
    WITH FRAME acct-fr. 
END PROCEDURE. 

Notes
See also

Class-based data member access, DEFINE BUFFER statement, DEFINE VARIABLE statement, FORM statement, Frame phrase, RUN statement


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex