SCROLL frame-phrase
FROM-CURRENT UP DOWN |
DEFINE VARIABLE ans AS CHARACTER NO-UNDO FORMAT "x".
FORM Customer.CustNum Customer.Name Customer.CreditLimit 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 NO-LOCK. DISPLAY Customer.CustNum Customer.Name Customer.CreditLimit 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 Customer.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. |
DEFINE VARIABLE counter AS INTEGER NO-UNDO.
DEFINE VARIABLE oldchoice AS CHARACTER NO-UNDO. FORM Customer.CustNum Customer.Name Customer.Address Customer.City WITH FRAME cust-frame SCROLL 1 5 DOWN ATTR-SPACE. FIND FIRST Customer NO-LOCK. REPEAT counter = 1 TO 5: DISPLAY Customer.CustNum Customer.Name Customer.Address Customer.City WITH FRAME cust-frame. DOWN WITH FRAME cust-frame. FIND NEXT Customer NO-LOCK 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.CustNum 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 Customer.CustNum = 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 NO-LOCK. DOWN WITH FRAME cust-frame. DISPLAY Customer.CustNum Customer.Name Customer.Address Customer.City WITH FRAME cust-frame. NEXT. END. /* KEYCODE("CURSOR-DOWN") */ IF LASTKEY = KEYCODE("CURSOR-UP") THEN DO: FIND PREV Customer NO-LOCK NO-ERROR. IF NOT AVAILABLE Customer THEN FIND LAST Customer NO-LOCK. UP WITH FRAME cust-frame. DISPLAY Customer.CustNum Customer.Name Customer.Address Customer.City WITH FRAME cust-frame. NEXT. END. /* KEYCODE("CURSOR-UP") */ /* 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 Customer.CustNum Customer.Name Customer.Address Customer.city WITH FRAME cust-frame. oldchoice = INPUT Customer.CustNum. NEXT. END. /* KEYCODE("c") */ IF LASTKEY = KEYCODE("d") THEN DO: /* Delete a customer. */ 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 last screen line deleted */ IF FRAME-LINE(cust-frame) = FRAME-DOWN(cust-frame) THEN DO:/* DISPLAY Customer.CustNum Customer.Name Customer.Address Customer.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 Customer.CustNum = "" THEN DISPLAY Customer.CustNum Customer.Name Customer.Address Customer.City WITH FRAME cust-frame. END. UP counter - 1 WITH FRAME cust-frame. oldchoice = INPUT Customer.CustNum. END. /* KEYCODE("d") */ END. /* REPEAT */ STATUS DEFAULT. |
. . .
IF LASTKEY = KEYCODE("d") THEN DO: /* Delete a customer. */ 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 Customer.CustNum Customer.Name Customer.Address Customer.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 Customer.CustNum. END. /* KEYCODE("d") */ . . . |
FORM Customer.CustNum 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.CustNum Customer.Name WITH FRAME cust-frame. DOWN WITH FRAME cust-frame. END. UP 5 WITH FRAME cust-frame. REPEAT: CHOOSE ROW Customer.CustNum NO-ERROR WITH FRAME cust-frame. FIND Customer WHERE Customer.CustNum = INPUT Customer.CustNum. 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.CustNum 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.CustNum 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. |