undo Command

Undo one or more sets of file changes.

Scope: File

Syntax

Parameter

Number 
A positive or negative integer value. If not specified, the default is 1.

Description

The undo command lets you restore the document to a previous state by undoing or redoing (undoing an undo) sets of changes (generations) to a document. These sets of changes are recorded using the check command, or more usually, the autocheck parameter, provided the recording parameter is set to on.

Depending on the value specified for Number, the undo command handles changes to a document as follows:

No value specified Undo the last change to document, and decrement the value of the changes parameter by 1.
Positive integer Undo the most recent number of changes specified by Number, and decrement the value stored in the changes parameter by the value of Number.
Negative integer Redo the most recent number of undos specified by Number, and increment the value stored in the changes parameter by the value of Number.

You can perform any combination or number of undo and redo operations until a change is made to the document. Once you have made that change, the undo operation becomes a single undoable change, regardless of the number of undo and redo operations just performed.

Examples

The examples refer to the following states of a file:

line1     line1     line1     line1     line1 
line2     line2     line2     line2 
line3     line3     line3 
line4     line4 
line5 
State E   State D   State C   State B   State A 
Most                                    Oldest
recent                                  version
version 

The file starts in state A and is progressively changed to state B, then C, then D, then E. A checkpoint is taken between each state.

  1. To revert to state B, one state at a time, type the following command three times:
    undo

    The first undo changes the file to state D, the second undo to state C and the third undo to state B. If there are no more changes to undo, the following message is displayed:

    No recorded changes available for UNDO 
  2. To revert 3 states directly from, for example, state E, type:
    undo 3 

    State B becomes the current state.

  3. Now if you type:
    undo -2

    The last two undos are undone, and the document returns to state D.

API Return Codes

-1 
Parameter specified is not a number.
-5 
You cannot make changes to the file because the readonly parameter is set to on.

autocheck Parameter
check Command
recording Parameter
changes