Try OpenEdge Now
skip to main content
ABL Reference
ABL Syntax Reference : EDITING phrase
 

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 ix 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 ix.
r-edit.p
DEFINE VARIABLE ix AS INTEGER NO-UNDO.

UPDATE ix 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 SalesRep.
While in the SalesRep field, the user can press SPACEBAR to scroll through the possible values for the SalesRep 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 SalesRep field, the terminal beeps.
r-edit2.p
PROMPT-FOR Customer.CustNum.
FIND Customer USING Customer.CustNum.

/* Update Customer fields, monitoring each keystroke during the UPDATE */
UPDATE Customer.Name Customer.Address Customer.City Customer.State SKIP
  Customer.SalesRep HELP "Use the space bar to select a SalesRep"
  WITH 2 COLUMNS EDITING: /* Read a keystroke */
  READKEY.
  /* If the cursor is in any field except SalesRep, execute the last key
     pressed and go on to the next iteration of this EDITING phrase to check
     the next key */
  IF FRAME-FIELD <> "SalesRep" THEN DO:
    APPLY LASTKEY.
    IF GO-PENDING THEN LEAVE.
    ELSE NEXT.
  END.
  /* When in the SalesRep 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.SalesRep @ Customer.SalesRep.
    NEXT.
  END.
  /* If the user presses any one of a set of keys while in the SalesRep 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 the AVM 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, the AVM executes the next iteration of that EDITING phrase and cancels any pending GO.
*When you use the LEAVE statement in an EDITING phrase, the AVM 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, the AVM 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