Progress
Language Reference


UNDO Statement

Interfaces
OS
SpeedScript
All
All
Yes

Backs out all modifications to fields and variables made during the current iteration of a block, and indicates what action to take next.

SYNTAX

UNDO
  [ label ]
  [     , LEAVE [ label2 ] 
     |  , NEXT [ label2 ] 
     |  , RETRY [ label1 ] 
     |  , RETURN [ ERROR | NO-APPLY ] [ return-value  ] 
  ] 

label1

The name of the block whose processing you want to undo. If you do not name a block with label1, UNDO undoes the processing of the closest transaction or subtransaction block. In determining the closest transaction or subtransaction block, Progress disregards DO ON ENDKEY blocks that do not have the ON ERROR or TRANSACTION option.

LEAVE label2

Indicates that after undoing the processing of a block, Progress leaves the block you name with label2. If you do not name a block with the LEAVE option, Progress leaves the block that was undone. After leaving a block, Progress continues on with any remaining processing in a procedure.

NEXT label2

Indicates that after undoing the processing of a block, Progress does the next iteration of the block you name with label2. If you do not name a block, Progress does the next iteration of the block that was undone.

RETRY label1

Indicates that after undoing the processing of a block, Progress repeats the same iteration of the block you name with label1. If you name a block with label1 it must be the name of the block that was undone.

RETRY is the default processing if you do not use LEAVE, NEXT, RETRY, or RETURN. When a block is retried, any frames scoped to that block are not advanced or cleared. For more information, see the Progress Programming Handbook .

RETURN [ ERROR | NO-APPLY ]

Returns to the calling procedure or to the Progress Editor (if there was no calling procedure). You can specify NO-APPLY within a user-interface trigger to prevent Progress from doing anymore handling for the event. In other contexts, you can use the ERROR option to raise the ERROR condition in the caller.

return-value

You can use return-value to return a value to the caller.

EXAMPLE

The r-undo.p procedure prompts you for the initials of a sales representative. If the initials match those of an existing sales representative, the procedure displays that sales representative’s record. Otherwise, it prompts you to add another sales representative with the initials you supplied. If you enter no, the UNDO statement undoes the work you have done since the start of the REPEAT block and lets you enter another set of initials.

r-undo.p
DEFINE VARIABLE ans AS LOGICAL.
REPEAT FOR salesrep WITH ROW 7 1 COLUMN 1 DOWN CENTERED
    ON ENDKEY UNDO, LEAVE:
  PROMPT-FOR sales-rep.
  FIND salesrep USING sales-rep NO-ERROR.
  IF NOT AVAILABLE salesrep
  THEN DO:
    ans = yes.
    MESSAGE "Salesrep record does not exist.".
    MESSAGE "Do you want to add a salesrep?" UPDATE ans.
    IF ans THEN DO:
      CREATE salesrep.
      ASSIGN sales-rep.
      UPDATE rep-name region month-quota.
    END.
    ELSE UNDO, RETRY.
  END.
  ELSE DISPLAY salesrep.
END. 

NOTES

SEE ALSO

ON ENDKEY Phrase, ON ERROR Phrase, RETRY Function


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