# Command History Object Documentation

Mark L. Ulferts

        mulferts@austin.dsccc.com

Glenn Durfee

### Name

ch_open - create and manipulate a command history object.

### SYNOPSIS

ch_open[chName]

### DESCRIPTION

The ch_open command creates a new command history object (given by the chName argument). The ch_open command returns its chName argument. At the time this command is invoked, there must not exist a command history object named chName.

### METHODS

The ch_open command creates a new Tcl command whose name is chName. This command may be used to invoke various operations on the command history object. It has the following general form:

chName option ?arg arg ...?

Option and theargs determine the exact behavior of the command. The following commands are possible for command history objects:

chName add command_string chName addM command_string

Add a command to the history and reset the current command pointer.

chName curr

Return the current command in the history.

chName history

Return the entire history.

chName next

Return the next command in the history making that the current command.

chName prev

Return the previous command in the history making that the current command.

### EXAMPLE

The following sequence creates a command history object, adds commands and traverses the history.

    cwish> ch_open ch
    ch
    cwish> ch add "cmd1"
    cwish> ch add "cmd2"
    cwish> ch prev
    cmd2
    cwish> ch prev
    cmd1
    cwish> ch curr
    cmd1
    cwish> ch add "cmd3"
    cwish> ch prev
    cmd3
    cwish> ch prev
    cmd2
    cwish> ch next
    cmd3
    cwish> ch next
    cwish> ch history
    cmd1
    cmd2
    cmd3