Progress
Programming
Handbook


Scrolling Frames

Scrolling frames are specialized down or one-down frames that allow the user to move a highlight bar through multiple iterations of data. Most often, scrolling frames are down frames. You use the SCROLL Frame phrase option together with the CHOOSE statement to create this type of frame.

NOTE: This feature is supported for backward compatibility. You can usually use either a browse widget or selection list instead of CHOOSE and SCROLL. For more information on browse widgets, see Database Access." For information on selection lists, see Representing Data."

The SCROLL statement opens a row and moves data in a frame with multiple rows. You can use the SCROLL statement to scroll data up or down to display another line in a frame. The following procedure shows how you might use this statement:

p-scroll.p
DEFINE VARIABLE current_line AS INTEGER.

FORM customer.cust-num customer.name customer.address
     customer.city customer.postal-code
     WITH FRAME cust-frame SCROLL 1 5 DOWN WIDTH 90.

CURRENT-WINDOW:WIDTH-CHARS = 90.

FIND FIRST customer. 
REPEAT current_line = 1 TO 5:
    DISPLAY cust-num name address city postal-code
       WITH FRAME cust-frame.
    DOWN WITH FRAME cust-frame.
    FIND NEXT customer NO-ERROR.
    IF NOT AVAILABLE customer
    THEN LEAVE.
END.

UP 5 WITH FRAME cust-frame.

REPEAT:
   STATUS DEFAULT
      "Use up and down arrows. Enter C to create, D to delete".
    CHOOSE ROW customer.cust-num NO-ERROR GO-ON(CURSOR-RIGHT)
        WITH FRAME cust-frame.
    FIND customer WHERE cust-num = INTEGER(INPUT cust-num).
    
    /* React to moving cursor off the screen */
    IF LASTKEY = KEYCODE("CURSOR-DOWN")
    THEN DO:
        FIND NEXT customer NO-ERROR.
        IF NOT AVAILABLE customer
        THEN FIND FIRST customer.
        DOWN WITH FRAME cust-frame.
        DISPLAY cust-num name address city postal-code
          WITH FRAME cust-frame.
        NEXT.
    END.

    IF LASTKEY = KEYCODE("CURSOR-UP")
       THEN DO:
          FIND PREV customer NO-ERROR.
          IF NOT AVAILABLE customer
          THEN FIND LAST customer.
          UP WITH FRAME cust-frame.
          DISPLAY cust-num name address city postal-code
            WITH FRAME cust-frame.
          NEXT.
    END. 
     /* CHOOSE selected a valid key.  Check which key. */   
    IF KEYLABEL(LASTKEY) = "c"
       THEN DO:              
          /* Open a space in the frame */
          SCROLL FROM-CURRENT DOWN WITH FRAME cust-frame.
          CREATE customer.
          UPDATE cust-num name address city postal-code
            WITH FRAME cust-frame.
          NEXT.
    END.

    IF KEYLABEL(LASTKEY) = "d"
      THEN DO:       
        /* Delete a customer from the database */
        DELETE customer.
        SCROLL FROM-CURRENT WITH FRAME cust-frame.
        current_line = FRAME-LINE(cust-frame).
        DOWN FRAME-DOWN(cust-frame) - FRAME-LINE(cust-frame) - 1
          WITH FRAME cust-frame.
          /* Place cursor on last active line in frame */
        FIND customer WHERE cust-num = INTEGER(INPUT cust-num).
        FIND NEXT customer NO-ERROR.
        IF NOT AVAILABLE customer
        THEN FIND FIRST customer.
        DOWN WITH FRAME cust-frame.
        DISPLAY cust-num name address city postal-code
           WITH FRAME cust-frame.
        UP FRAME-LINE(cust-frame) - current_line
           WITH FRAME cust-frame.
           /* Move cursor back to where it was at start of block */
    END.
END.
STATUS DEFAULT.  

This procedure produces the following output:

Use the arrow keys to move the highlighted bar to the fifth customer. Type C for create.

At this point, you can add a new customer to the database by typing the customer information on the open line. The p-scroll.p procedure uses SCROLL and CHOOSE to allow the user to browse through information, then perform actions with the information.

The p-scroll.p procedure creates a scrolling frame of five fields. The frame displays the cust–num, name, address, city, and postal–code for each customer. The status default message displays “Enter C to create, D to delete” as long as the procedure runs. You use arrow keys to move the highlighted cursor bar through lines of the scrolling frame, and you can add or delete customers from the database. The CHOOSE statement allows you to move the highlight bar.

The SCROLL statement controls the scrolling action in the frame when you create and delete customers. You add a customer to the database by typing C. Create opens a line in the frame and the SCROLL statement moves data below the line down. Then you type the new customer information into the frame. You type D to delete a customer from the database. When you delete a customer, SCROLL moves the rows below the deleted customer row up into the empty line.

The p-scroll.p procedure works as follows:

The p-scroll.p procedure uses UP and DOWN statements to control the current cursor position. These statements behave differently with scrolling frames than with regular down frames. If the cursor is on the top line of a frame, the UP statement opens a line at the top of the screen and moves the remaining frames lines down one line. This is also what happens if you use the SCROLL DOWN statement. Similarly, if the cursor is on the bottom line of a frame, the DOWN statement opens a line at the bottom of the screen and moves the remaining frame lines down one line.


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