Progress
Programming
Handbook


Using Shared Frames

Sometimes you want several procedures to use the same frame. You might use the same frame throughout an application or with a few different procedures in an application. Progress lets you define a frame as shared, so that many procedures can use it. You use the DEFINE SHARED FRAME statement to define a shared frame. You must describe the shared frame in a FORM statement.

You can write a procedure to display customer information, another procedure to update order information, and you can display all the information in the same frame. One way to do this is to define a shared frame.

Figure 19–9 shows how two procedures can use the same frame.

p-dicust.p
p-updord.p
p-dicust.i

Figure 19–9: Shared Frames

The FORM statement in this example is in an include file, p-dicust.i. This file sets up and names the cust–frame:

p-dicust.i
FORM
     xcust.cust-num   COLON 10 LABEL "Cust #"
     xcust.name    COLON 10           xcust.phone        COLON 50
     xcust.address COLON 10           xcust.sales-rep    COLON 50
     csz     NO-LABEL COLON 12        xcust.credit-limit COLON 50
     SKIP (2)
     order.order-num    COLON 10      order.order-date   COLON 30
     order.ship-date    COLON 30
     order.promise-date COLON 30   WITH SIDE-LABELS 1 DOWN CENTERED ROW 5
        TITLE " CUSTOMER/ORDER FORM " FRAME cust-frame. 

Although you cannot run the p-dicust.i file by itself because it is only a FORM statement, the file describes the following frame:

The p-dicust.p procedure displays customer information in this frame:

p-dicust.p
DEFINE NEW SHARED FRAME cust-frame.
DEFINE NEW SHARED VARIABLE csz AS CHARACTER FORMAT "x(22)".
DEFINE NEW SHARED BUFFER xcust FOR customer.

REPEAT:
   {p-dicust.i}     /* include file for layout of shared frame */

   PROMPT-FOR xcust.cust-num WITH 1 DOWN FRAME cust-frame.
   FIND xcust USING xcust.cust-num NO-ERROR.
   IF NOT AVAILABLE(xcust)
   THEN DO:
      MESSAGE "Customer not found".
      NEXT.
   END.

   DISPLAY
      name phone address sales-rep
      city + ", " + state + " " + STRING(postal-code) @ csz
      credit-limit WITH FRAME cust-frame.

   RUN p-updord.p.    /* External procedure to update customer’s orders */

END. 

The p-dicust.p procedure displays customer information in the shared frame cust–frame and lets the user update the order information for the customer on the screen. The procedure defines the new shared frame named cust–frame and a new shared buffer, xcust, to store customer information. (You can use only one DEFINE SHARED FRAME statement per frame in a procedure.) The name cust–frame corresponds to the frame in the FORM statement in the p-dicust.i include file.

The procedure prompts the user for a customer number and displays the customer information for that customer using the frame defined in the p-dicust.i file. Then the procedure calls the p-updord.p procedure, shown below:

p-updord.p
DEFINE SHARED FRAME cust-frame.
DEFINE SHARED VARIABLE csz AS CHARACTER FORMAT "x(22)".
DEFINE SHARED BUFFER xcust FOR customer.

FOR EACH order OF xcust:
    {p-dicust.i}      /* include file for layout of shared frame */

    DISPLAY order.order-num WITH FRAME cust-frame.
    UPDATE order.order-date order.ship-date
           order.promise-date WITH FRAME cust-frame.
END. 

The p-updord.p procedure defines the shared frame cust–frame and the shared variable csz, which was first defined in the p-dicust.p procedure. It also defines the shared buffer to store customer information. You must use the DEFINE SHARED VARIABLE statement for the csz variable because variables named in a shared frame are not automatically shared variables. You must also use the DEFINE SHARED FRAME statement for the cust–frame so that Progress can recognize the frame.

The p-updord.p procedure finds the customer that the p-dicust.p procedure is using in the shared buffer, xcust. The procedure then displays the information for each order of the customer in the shared frame called cust–frame. Finally, the procedure allows the user to update the order information.

When you use shared frames, remember these important points:

See the Progress Language Reference for more information on the DEFINE FRAME statement.


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