HPlogo Using HP 3000 MPE/iX: Fundamental Skills Tutorial: HP 3000 MPE/iX Computer Systems > Chapter 2 Communicating with Your Computer

Lesson 5 The History Stack

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Glossary

 » Index

Lesson 5 presents reexecuting and editing commands in the history stack.

The history stack is a portion of the computer's memory where the computer records your most recent commands. It keeps them there for you to reuse or correct.

Having to reenter a complex command line could be tedious.

  • The LISTREDO command displays the commands in the history stack.

  • The DO command reexecutes commands in the history stack.

  • The REDO command edits and reexecutes commands in the history stack.

The DO command allows you to retrieve a complex command and reexecute it without having to reenter it.

The REDO command allows you to retrieve a command, edit it, and reexecute it without having to reenter the entire command.

NOTE: In order to do the following exercises, you must start a new session. If you are logged on, log off and then log back on again. Then follow the next steps exactly.
   BYEReturn

   HELLO your logon identityReturn

There is a reason for having you log off and log back on. Logging off clears the command line history stack. Logging back on starts you with an empty history stack; otherwise, the history stack would be cluttered with previous commands.

What is the command line history stack?

Each time you enter a command, your MPE/iX system saves that command in a list called the command line history stack. You may hear it called the redo stack.

In the command line history stack, each command is added at the bottom of the list as it is entered:

  • Only the 20 most recent commands are kept in the history stack (This number can be changed.)

  • The LISTREDO command shows you the commands kept in the history stack.

Enter these commands just the way they are shown here:

   CHOWMMReturn

   SHOWTIMEReturn

   SHOWJOBReturn

CHOWMM produces an error message. SHOWTIME and SHOWJOB produce the displays of the kind you have seen before.

Command history and the LISTREDO command

LISTREDO displays past commands.

Enter:

   LISTREDOReturn

Here is how your screen looks:

   :LISTREDO

      1) CHOWMM

      2) SHOWTIME

      3) SHOWJOB

      4) LISTREDO

All of the commands you issued, including the LISTREDO command itself, are stored in the history stack. They appear in the order you entered them.

The DO command

If you want to reexecute a command in the history stack without editing, use the DO command:

  • Typing DOReturn reexecutes the most recent command.

  • Typing DO N Return reexecutes command number N.

  • Typing DO never appears in the command line history stack.

For example, reexecute the third command you that entered (SHOWJOB).

Enter:

   DO 3Return

Did the SHOWJOB command execute?

Was it added to the history stack?

Enter:

   LISTREDOReturn

How would you use DO to reexecute the SHOWTIME command?

Enter:

   DO 2Return

Was it added to the history stack?

Enter:

   LISTREDOReturn

History stack numbering

The history stack by default holds only the last 20 commands of your current session. But the history stack never runs out of room. Instead, it continues recording commands by number, dropping the oldest command to make room for the newest command.

Suppose that the letters of the English alphabet (A through Z) were commands. If you were to use all 26 commands and then execute LISTREDO, you would see something like this:

:LISTREDO 

     8) H !!Commands A through G!!

     9) I !!(1 through 7) have "fallen"!!

    10) J !!out of the history stack.!!

    11) K !!They are no longer available!!

    12) L !!to REDO or DO.!!

    13) M 

    14) N !!The history stack continues!!

    15) O !!recording commands in the!!

    16) P !!absolute order in which!!

    17) Q !!they were executed.!!

    18) R 

    19) S !!Here the 8th command is!!

    20) T !!the "oldest" and the 27th!!

    21) U !!is the most recent.!!

    22) V 

    23) W !!The 28th command will!!

    24) X !!"push" the 8th command out!!

    25) Y !!of the history stack.!!

    26) Z

    27) LISTREDO

Command history and REDO

The REDO command works like the DO command, but with one difference: REDO allows you to edit a command in the command line history stack before you reexecute it.

  • Typing REDOReturn allows you to edit and reexecute the most recent command.

  • Typing REDO N Return allows you to edit and reexecute command number N.

  • The REDO command never appears in the command line history stack.

Enter :

   LISTREDOReturn

You should see the sequence of commands you have issued.

To edit the command that was entered incorrectly (CHOWMM) enter:

   REDO 1Return

Command 1 in your history stack is retrieved, ready for you to make corrections to it, using the REDO line editing methods you are now familiar with:

   CHOWMM

   RSReturn

   SHOWMM

        DReturn

   SHOWM

        IEReturn

   SHOWME

   Return

Try entering:

   LISTREDOReturn

Notice that the commands you that have issued have stacked up, one after the other.

HELLO never appears in the command line history stack.

NOTE: The DO and REDO commands work only with those commands still kept in the history stack. If the history stack contains commands 8 through 27, attempting REDO 3 produces an error message:

INVALID NUMERIC INDEX INTO THE REDO STACK (CIERR 9073)

Lesson 5 Exercises

  1. The command history stack is:

    1. a list of the system commands available to the user for correction or reexecution

    2. a list of the last 20 commands entered by a user in a session

    3. a list of all of the commands entered by a user in a session

  2. Which MPE/iX command lists the commands in your command history stack?

  3. Enter several commands that you know. After you have entered a couple of commands, display your command history stack to your terminal screen. Then enter a misspelled command. How is it recorded in the history stack?

  4. Which MPE/iX commands never appear in your command line history stack?

    1. DO

    2. HELLO

    3. REDO

    4. LISTREDO

  5. Given a maximum history stack size of 20, what range of numbers is displayed by LISTREDO if the LISTREDO is command number 45?

  6. Display your command history stack on the screen. Use DO or REDO with or without specifying command numbers to reexecute several of the commands in your command history stack.

Feedback to webmaster