Progress
Language Reference


EDITING Phrase

Interfaces
OS
SpeedScript
All
All
No

Identifies the process that follows each keystroke during a PROMPT-FOR, SET, or UPDATE statement. This is maintained primarily for compatibility with Progress Version 6 or earlier.

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

SEE ALSO

END Statement, PROMPT-FOR Statement, READKEY Statement, SET Statement, UPDATE Statement


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