Release 10.1A: OpenEdge Development:
Progress 4GL Reference

> ## SCROLL statement

> Moves data up or down in a frame with multiple rows. Use the SCROLL statement to scroll data up or down when you add or delete a line in a frame.

> This statement is supported only for backward compatibility.

> Note: Does not apply to SpeedScript programming.

> #### Syntax

>     SCROLL
>       [ FROM-CURRENT ]
>       [ UP | DOWN ]
>       { [ frame-phrase ] }

> `FROM-CURRENT`

> Scrolls UP or DOWN rows of data at or below the current cursor location. When scrolling UP, a new line opens at the bottom of the frame. When scrolling DOWN, a new line opens at the current cursor location. For example:

> If you do not use the FROM-CURRENT option, then the entire frame scrolls up or down and the newly opened line appears at the top or bottom of a frame, respectively.

> FROM-CURRENT limits scrolling from the current cursor position to the bottom of the frame.

> `UP`

> Scrolls rows of data up and off the frame and opens a line at the bottom of the frame. UP is the default. For example:

> `DOWN`

> Scrolls rows of data down and off the frame and opens a line at the top of the frame. For example, the Original Frame in the next example shows four rows of data. The highlighted bar is the current cursor position and the frame is a scrolling frame. On the right, the SCROLL FROM-CURRENT DOWN statement opens a line in the frame at the current cursor location and moves the other rows down and off the frame. For example:

> In the next example, the SCROLL DOWN statement opens a line at the top of the frame and moves the other rows of data down and off the frame:

> ``frame-phrase``

> Specifies the overall layout and processing properties of a frame. For more information on `frame-phrase`, see the Frame phrase reference entry.

> Examples

> This procedure displays customer information and lets you try each scrolling option from a menu of selections:

> r-scroll.p
>     DEFINE VARIABLE ans AS CHARACTER FORMAT "x".

>     FORM cust.cust-num cust.name credit-limit
>        WITH FRAME cust CENTERED 10 DOWN.

>     FORM  "1 - scroll up" SKIP
>           "2 - scroll from-current up" SKIP
>           "3 - scroll down" SKIP
>           "4 - scroll from-current down" SKIP
>           "5 - scroll from-current "
>     WITH FRAME instruct CENTERED TITLE "Instructions:".

>     VIEW FRAME cust.

>     REPEAT WHILE FRAME-LINE(cust) <= FRAME-DOWN(cust):
>        FIND NEXT customer.
>        DISPLAY cust-num name credit-limit WITH FRAME cust TITLE "Customers".
>        DOWN WITH FRAME cust.
>     END.

>     UP FRAME-DOWN(cust) / 2 WITH FRAME cust.

>     VIEW FRAME instruct.REPEAT WITH FRAME cust:
>        CHOOSE ROW cust.name KEYS ans AUTO-RETURN NO-ERROR WITH FRAME cust.
>        IF ans = "1" THEN SCROLL UP.
>        ELSE IF ans = "2" THEN SCROLL FROM-CURRENT UP.
>        ELSE IF ans = "3" THEN SCROLL DOWN.
>        ELSE IF ans = "4" THEN SCROLL FROM-CURRENT DOWN.
>        ELSE IF ans = "5" THEN SCROLL FROM-CURRENT.
>        VIEW FRAME cust.
>        ans = "".
>     END.

> The next procedure creates a scrolling frame of five iterations. The frame displays the `cust-num`, `name`, `address`, and `city` for each customer. The status default message displays “Enter C to create, D to delete” as long as the procedure is running. You use arrow keys to move the highlighted cursor bar through the database, and to add or delete customers from the database. The CHOOSE statement lets you easily create this style menu. See the CHOOSE statement reference entry for more information.

> r-chose1.p
>     DEFINE VARIABLE counter AS INTEGER.
>     DEFINE VARIABLE oldchoice AS CHARACTER.

>     FORM customer.cust-num customer.name customer.address customer.city
>         WITH FRAME cust-frame SCROLL 1 5 DOWN ATTR-SPACE.

>     FIND FIRST customer.
>     REPEAT counter = 1 TO 5:
>         DISPLAY cust-num name address city 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.
>     oldchoice = "".

>     REPEAT:
>         STATUS DEFAULT "Enter C to create, D to delete".
>         CHOOSE ROW customer.cust-num NO-ERROR GO-ON(CURSOR-RIGHT)
>            WITH FRAME cust-frame.

>         /* After choice */
>         IF FRAME-VALUE = ""
>         THEN NEXT.
>         /* Force user to press END or move cursor to valid line */
>         IF FRAME-VALUE <> oldchoice
>         THEN DO:
>             oldchoice = FRAME-VALUE.
>             FIND customer WHERE cust-num = INTEGER(FRAME-VALUE).
>         END.
>         /* 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 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 WITH FRAME cust-frame.
>            NEXT.
>        END.
>        /* CHOOSE selected a valid key.  Check which key. */
>        IF LASTKEY = KEYCODE("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 WITH FRAME cust-frame.
>            oldchoice = INPUT cust-num.
>            NEXT.
>        END.
>        IF LASTKEY = KEYCODE("d")
>        THEN DO: /* Delete a customer from the database. */
>             DELETE customer.
>             FIND NEXT customer NO-ERROR.
>             /* Move to correct position in database. */
>            IF NOT AVAILABLE customer
>            THEN DO:
>                FIND FIRST customer NO-ERROR.
>                IF NOT AVAILABLE customer
>                THEN DO:
>                    CLEAR FRAME cust-frame.
>                    UP WITH FRAME cust-frame.
>                    NEXT.
>                END.
>            END.
>           IF FRAME-LINE(cust-frame) = FRAME-DOWN(cust-frame)
>           THEN DO:/* If last screen line deleted */
>                DISPLAY cust-num name address city WITH FRAME cust-frame.
>                NEXT.
>           END.
>           SCROLL FROM-CURRENT WITH FRAME cust-frame.
>           REPEAT counter = 1 TO 100
>                 WHILE FRAME-LINE(cust-frame) < FRAME-DOWN(cust-frame):
>               FIND NEXT customer NO-ERROR.
>               IF NOT AVAILABLE customer
>               THEN DO:
>                   FIND FIRST customer NO-ERROR.
>                  IF NOT AVAILABLE customer
>                  THEN LEAVE.
>               END.
>               DOWN WITH FRAME cust-frame.
>               IF INPUT cust-num = ""
>               THEN DISPLAY cust-num name address city WITH FRAME cust-frame.
>           END.
>           UP counter - 1 WITH FRAME cust-frame.
>           oldchoice = INPUT cust-num.
>        END.
>     END.
>     STATUS DEFAULT.

> The SCROLL statement controls the scrolling action in the frame when you create and delete customers. To add a customer to the database, type 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. Type D to delete a customer from the database. When you delete a customer, all rows below the deleted customer row move up one row.

> You can perform the same function with fewer statements if you do not use the SCROLL statement. You can substitute the `r-chose1.p` procedure segment with the `r-chose2.p` to perform the delete function.

> r-chose2.p
>                         .
>                         .
>                         .
>     IF LASTKEY = KEYCODE("d")
>     THEN DO: /* Delete a customer from the database. */
>       DELETE customer.
>       REPEAT counter = 1 TO 100 WHILE FRAME-LINE(cust-frame)
>           <= FRAME-DOWN(cust-frame).
>         FIND NEXT customer NO-ERROR.
>         IF AVAILABLE customer
>         THEN DISPLAY cust-num name address city
>            WITH FRAME cust-frame.
>         ELSE CLEAR FRAME cust-frame.
>         DOWN WITH FRAME cust-frame.
>       END.
>       UP counter - 1 WITH FRAME cust-frame.
>       oldchoice = INPUT cust-num.
>     END.
>                         .
>                         .
>                         .

> You can see the entire `r-chose2.p` procedure on-line. This example only shows the portion that is different from the `r-chose1.p` procedure.

> The `r-cuhelp.p` procedure provides help for the cust-num field when a user presses HELP. It displays five customer names and numbers. The user can press (UP-ARROW), (DOWN-ARROW), to scroll down, or (RETURN) to exit.

> r-cuhelp.p
>     FORM customer.cust-num customer.name
>       WITH FRAME cust-frame 5 DOWN ROW 10 CENTERED
>       OVERLAY TITLE " Available Customers ".

>     REPEAT WHILE FRAME-LINE(cust-frame) <= FRAME-DOWN(cust-frame):
>       FIND NEXT customer.
>       DISPLAY customer.cust-num customer.name
>         WITH FRAME cust-frame.
>         DOWN WITH FRAME cust-frame.
>     END.

>     UP 5 WITH FRAME cust-frame.

>     REPEAT:
>       CHOOSE ROW customer.cust-num NO-ERROR
>         WITH FRAME cust-frame.
>       FIND customer WHERE customer.cust-num = INPUT
>         customer.cust-num.
>       IF KEYFUNCTION(LASTKEY) = "CURSOR-UP" THEN DO:
>         FIND PREV customer NO-ERROR.
>         IF AVAILABLE customer THEN DO:
>           SCROLL DOWN WITH FRAME cust-frame.
>           DISPLAY customer.cust-num customer.name
>           WITH FRAME cust-frame.
>         END.
>       END.
>       ELSE
>       IF KEYFUNCTION(LASTKEY) = "CURSOR-DOWN" THEN DO:
>         FIND NEXT customer NO-ERROR.
>         IF AVAILABLE customer THEN DO:
>           SCROLL UP WITH FRAME cust-frame.
>           DISPLAY customer.cust-num customer.name
>             WITH FRAME cust-frame.
>         END.
>       END.
>       ELSE
>       IF KEYFUNCTION(LASTKEY) = "RETURN" THEN DO:
>         FRAME-VALUE = FRAME-VALUE.
>         HIDE FRAME cust-frame.
>         RETURN.
>       END.
>     END.

> #### See also

> CHOOSE statement, Frame phrase

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