1<HTML><HEAD><TITLE>Built-In Commands - history manual page</TITLE></HEAD><BODY>
2<DL>
3<DD><A HREF="history.htm#M2" NAME="L512">NAME</A>
4<DL><DD>history - Manipulate the history list</DL>
5<DD><A HREF="history.htm#M3" NAME="L513">SYNOPSIS</A>
6<DL>
7<DD><B>history </B>?<I>option</I>? ?<I>arg arg ...</I>?
8</DL>
9<DD><A HREF="history.htm#M4" NAME="L514">DESCRIPTION</A>
10<DL>
11</DL>
12<DL>
13<DD><A HREF="history.htm#M5" NAME="L515"><B>history</B></A>
14<DD><A HREF="history.htm#M6" NAME="L516"><B>history add</B><I> command </I>?<B>exec</B>?</A>
15<DD><A HREF="history.htm#M7" NAME="L517"><B>history change</B><I> newValue</I> ?<I>event</I>?</A>
16<DD><A HREF="history.htm#M8" NAME="L518"><B>history clear</B></A>
17<DD><A HREF="history.htm#M9" NAME="L519"><B>history event</B> ?<I>event</I>?</A>
18<DD><A HREF="history.htm#M10" NAME="L520"><B>history info </B>?<I>count</I>?</A>
19<DD><A HREF="history.htm#M11" NAME="L521"><B>history keep </B>?<I>count</I>?</A>
20<DD><A HREF="history.htm#M12" NAME="L522"><B>history nextid</B></A>
21<DD><A HREF="history.htm#M13" NAME="L523"><B>history redo </B>?<I>event</I>?</A>
22</DL>
23<DD><A HREF="history.htm#M14" NAME="L524">HISTORY REVISION</A>
24<DD><A HREF="history.htm#M15" NAME="L525">KEYWORDS</A>
25</DL><HR>
26<H3><A NAME="M2">NAME</A></H3>
27history - Manipulate the history list
28<H3><A NAME="M3">SYNOPSIS</A></H3>
29<B>history </B>?<I>option</I>? ?<I>arg arg ...</I>?<BR>
30<H3><A NAME="M4">DESCRIPTION</A></H3>
31The <B>history</B> command performs one of several operations related to
32recently-executed commands recorded in a history list.  Each of
33these recorded commands is referred to as an ``<A HREF="../TkCmd/event.htm">event</A>''.  When
34specifying an event to the <B>history</B> command, the following
35forms may be used:
36<P>
37<DL>
38<DT>[1]<DD>
39A number:  if positive, it refers to the event with
40that number (all events are numbered starting at 1).  If the number
41is negative, it selects an event relative to the current event
42(<B>-1</B> refers to the previous event, <B>-2</B> to the one before that, and
43so on).  Event <B>0</B> refers to the current event.
44<P><DT>[2]<DD>
45A string:  selects the most recent event that matches the string.
46An event is considered to match the string either if the string is
47the same as the first characters of the event, or if the string
48matches the event in the sense of the <B><A HREF="../TclCmd/string.htm">string match</A></B> command.
49<P></DL>
50<P>
51The <B>history</B> command can take any of the following forms:
52<P>
53<DL>
54<DT><A NAME="M5"><B>history</B></A><DD>
55Same
56as <B>history info</B>, described below.
57<P><DT><A NAME="M6"><B>history add</B><I> command </I>?<B>exec</B>?</A><DD>
58Adds the <I>command</I> argument to the history list as a new event.  If
59<B>exec</B> is specified (or abbreviated) then the command is also
60executed and its result is returned.  If <B>exec</B> isn't specified
61then an empty string is returned as result.
62<P><DT><A NAME="M7"><B>history change</B><I> newValue</I> ?<I>event</I>?</A><DD>
63Replaces the value recorded for an event with <I>newValue</I>.  <I>Event</I>
64specifies the event to replace, and
65defaults to the <I>current</I> event (not event <B>-1</B>).  This command
66is intended for use in commands that implement new forms of history
67substitution and wish to replace the current event (which invokes the
68substitution) with the command created through substitution.  The return
69value is an empty string.
70<P><DT><A NAME="M8"><B>history clear</B></A><DD>
71Erase the history list.  The current keep limit is retained.
72The history event numbers are reset.
73<P><DT><A NAME="M9"><B>history event</B> ?<I>event</I>?</A><DD>
74Returns the value of the event given by <I>event</I>.  <I>Event</I>
75defaults to <B>-1</B>.
76<P><DT><A NAME="M10"><B>history info </B>?<I>count</I>?</A><DD>
77Returns a formatted string (intended for humans to read) giving
78the event number and contents for each of the events in the history
79list except the current event.  If <I>count</I> is specified
80then only the most recent <I>count</I> events are returned.
81<P><DT><A NAME="M11"><B>history keep </B>?<I>count</I>?</A><DD>
82This command may be used to change the size of the history list to
83<I>count</I> events.  Initially, 20 events are retained in the history
84list.  If <I>count</I> is not specified, the current keep limit is returned.
85<P><DT><A NAME="M12"><B>history nextid</B></A><DD>
86Returns the number of the next event to be recorded
87in the history list.  It is useful for things like printing the
88event number in command-line prompts.
89<P><DT><A NAME="M13"><B>history redo </B>?<I>event</I>?</A><DD>
90Re-executes the command indicated by <I>event</I> and returns its result.
91<I>Event</I> defaults to <B>-1</B>.  This command results in history
92revision:  see below for details.
93<P></DL>
94<H3><A NAME="M14">HISTORY REVISION</A></H3>
95Pre-8.0 Tcl had a complex history revision mechanism.
96The current mechanism is more limited, and the old
97history operations <B>substitute</B> and <B>words</B> have been removed.
98(As a consolation, the <B>clear</B> operation was added.)
99<P>
100The history option <B>redo</B> results in much simpler ``history revision''.
101When this option is invoked then the most recent event
102is modified to eliminate the history command and replace it with
103the result of the history command.
104If you want to redo an event without modifying history, then use
105the <B><A HREF="../TkCmd/event.htm">event</A></B> operation to retrieve some event,
106and the <B>add</B> operation to add it to history and execute it.
107
108<H3><A NAME="M15">KEYWORDS</A></H3>
109<A href="../Keywords/E.htm#event">event</A>, <A href="../Keywords/H.htm#history">history</A>, <A href="../Keywords/R.htm#record">record</A>
110<HR><PRE>
111<A HREF="../copyright.htm">Copyright</A> &#169; 1993 The Regents of the University of California.
112<A HREF="../copyright.htm">Copyright</A> &#169; 1994-1997 Sun Microsystems, Inc.
113<A HREF="../copyright.htm">Copyright</A> &#169; 1995-1997 Roger E. Critchlow Jr.</PRE>
114</BODY></HTML>
115