Release 10.1A: OpenEdge Development:
Progress 4GL Reference

> ## EDITING phrase

> Identifies the process that follows each keystroke during a PROMPT-FOR, SET, or UPDATE statement.

> This phrase is maintained primarily for compatibility with Progress Version 6 or earlier.

> Note: Does not apply to SpeedScript programming.

> #### Syntax

>     [ label: ] EDITING: statement ... END

> ``statement``

> One or more statements you want to process, usually for each keystroke entered. In most cases, the first statement is READKEY.

> Example

> This procedure lets you update the i variable, and immediately processes each of your keystrokes. The READKEY statement reads each of the keys you press. The APPLY statement applies, or executes, each keystroke. This is a very simple EDITING phrase and is the same as entering UPDATE i.

> r-edit.p
>     DEFINE VARIABLE i AS INTEGER.

>     UPDATE i EDITING:
>       READKEY.
>       APPLY LASTKEY.
>     END.

> The following r-edit2.p procedure uses an EDITING phrase with an UPDATE statement to control what happens based on each keystroke during the UPDATE. Here, the user can press any key while updating any field except sales-rep.

> While in the sales-rep field, the user can press SPACEBAR to scroll through the possible values for the sales-rep field. If the user presses the TAB, BACKTAB, GO, RETURN, or END-ERROR key, the procedure executes that key. If the user presses any other key while in the sales-rep field, the terminal beeps.

> r-edit2.p
>     PROMPT-FOR customer.cust-num.
>     FIND customer USING cust-num.

>     /* Update customer fields, monitoring each keystroke during the UPDATE */
>     UPDATE name address city state SKIP
>            sales-rep HELP "Use the space bar to select a sales-rep"
>            WITH 2 COLUMNS
>         EDITING:  /* Read a keystroke */
>           READKEY.
>           /* If the cursor is in any field except sales-rep, execute the
>              last key pressed and go on to the next iteration of this
>              EDITING phrase to check the next key */
>          IF FRAME-FIELD <> "sales-rep" THEN DO:
>             APPLY LASTKEY.
>             IF GO-PENDING THEN LEAVE.
>             ELSE NEXT.
>          END.
>          /* When in the sales-rep field, if the last key pressed was
>             the space bar then cycle through the sales reps */
>          IF LASTKEY = KEYCODE(" ") THEN DO:
>             FIND NEXT salesrep NO-ERROR.
>             IF NOT AVAILABLE salesrep THEN FIND FIRST salesrep.
>             DISPLAY salesrep.sales-rep @ customer.sales-rep.
>             NEXT.
>          END.
>          /* If the user presses any one of a set of keys while in the
>             sales-rep field, immediately execute that key */
>          IF LOOKUP(KEYFUNCTION(LASTKEY),
>                    "TAB,BACK-TAB,GO,RETURN,END-ERROR") > 0
>          THEN APPLY LASTKEY.
>          ELSE BELL.
>     END.

> #### Notes

> - A READKEY statement does not have to be the first statement after the word EDITING. However, it should appear somewhere in the EDITING phrase because Progress does not automatically read keystrokes when you use an EDITING phrase.

> - The EDITING phrase applies to the PROMPT-FOR part of a SET or UPDATE statement. Therefore, to examine a value supplied by the user (within an EDITING phrase), you must use the INPUT function to refer to the field or variable that contains the value.

> - When you use the NEXT statement in an EDITING phrase, Progress executes the next iteration of that EDITING phrase and cancels any pending GO.

> - When you use the LEAVE statement in an EDITING phrase, Progress leaves the EDITING phrase and executes the assignment part of the SET or UPDATE statement.

> - Within an EDITING phrase, you cannot use the CLEAR ALL, DOWN, or UP statements on the frame being edited.

> - If you hide and redisplay a frame while you are in an EDITING block, Progress might not redisplay it in the same location unless you specifically name the row and column of the frame. This could cause problems because the EDITING block does not recognize the new location, and attempts to update the fields at the old frame location.

> - The EDITING phrase activates only for input from a terminal. If your input comes from an operating system file (set with the INPUT FROM statement), the EDITING phrase has no effect.

> - The EDITING phrase is incompatible with event-driven programming. An EDITING block might interfere with other event handling statements.

> - For more information on EDITING blocks and other ways of monitoring keystrokes, see OpenEdge Development: Programming Interfaces .

> #### See also

> END statement, PROMPT-FOR statement, READKEY statement, SET statement, UPDATE statement

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