Lesson 6 The Command Interpreter [ Using the 900 Series HP 3000: Advanced Skills Module 5: User Commands ] MPE/iX 5.0 Documentation
Using the 900 Series HP 3000: Advanced Skills Module 5: User Commands
Lesson 6 The Command Interpreter
Introduction
Lesson 6 presents two basic uses of the command interpreter:
* toggling between an editor and the operating system when compiling
and linking a program
* toggling between an editor and the operating system when testing a
command file
NOTE This lesson is primarily for programmers and system managers. You
can skip the lesson if you perform neither programmer nor system
manager functions.
If you plan to write programs or command files, you will often use the
editor to edit the file, keep the file, exit the editor, and return to
the operating system to compile and run the program or execute the
command file. This process can get tedious when you must do continual
editing and error checking. It would be most convenient at such times to
be able to toggle between the editor and the operating system; however,
pressing the Break key or pressing CTRL Y does not allow you to toggle
between the editor and the operating system, and actually execute any
commands at the operating system level. So, what does? The command
interpreter (CI).
NOTE It is also possible to toggle by entering :MPE/iX command-name at
the editor prompt.
In this lesson, you will learn to do the following:
* use the CI to toggle between the editor and the operating system
when modifying source code or command files
Using the CI
The command interpreter (CI) is the program that acts as the interface
between you and the operating system. It checks the MPE/iX commands that
you enter for spelling and syntax errors. The CI then passes the command
along to the appropriate system procedure for execution. Following
execution, control returns to the CI, which becomes ready for another
command.
You can run the CI from within the editor and then enter the MPE/iX
commands necessary to compile, link, and run a program. Then, by
entering EXIT, you can immediately return to the editor. You can also
run the CI from within the CI.
NOTE To run the CI, either the user or the program must have PH
capability. The editor does not have PH capability (confirmed
earlier with the VERSION command), so the user must have PH
capability. To use nested levels of the CI, the user must have PH
capability.
You can enter SHOWVAR HPCIDEPTH to learn your CI level. When CI is
run from the editor, HPCIDEPTH=2. The main CI level (root) is
HPCIDEPTH=1.
To run the CI, enter the following command at the editor prompt (/):
:RUN CI.PUB.SYS
or
:XEQ CI
To exit the CI and return to the editor, enter:
EXIT
Figure 5-13. The CI
To demonstrate the assistance that the CI can provide you during program
development, follow along with the teaching exercise below. If you are a
system manager, skip ahead to teaching exercise 5-7.
Teaching exercise 5-6 for programmers: using the command interpreter.
1. There is a C program in your ACCTx account and CLASS group called
HIC. You will be compiling, linking, modifying, and running the
program using the CI and the editor. It purposely has some hidden
bugs in it so that it does not compile successfully the first time
that you try to do so.
2. First, compile and link the program using the command line shown
below:
CCXLLK HIC,HICP
where:
a. HIC is the source code.
b. HICP is the compiled and linked, executable code.
c. The error listing will appear on the screen and not be
stored in a file. (No error listing file was specified in
the command line.)
d. When compiling and linking is completed, an END OF PROGRAM
message will appear on the screen.
The general syntax for compiling and linking a program is
CCXLLK source_code, executable_code[,error_listing]
__________________________________________________________
NOTE Since errors do occur during compiling and linking,
you will eventually have to modify the source code
and correct the errors so that the program will run
successfully.
__________________________________________________________
3. Edit the source file, make the necessary changes, and save the
file. The error is clearly noted at the beginning of the source
code after the DEFINE section. The correction that you should
make is also explained.
EDITOR
/T HIC
/LIST 8/30
Notice that on or near line 23 there is an error. You can now
make the specified changes using standard editing commands
(M[ODIFY], R[EPLACE], I[NSERT])
Now keep the file:
/K HIC
4. Toggle back to the operating system by using the CI. Type:
:RUN CI.PUB.SYS
or
:XEQ CI
Compile and link the program as you did before. It should compile
and link without errors.
5. Run the program by entering the following:
HICP
6. The program should prompt you for your logon user name, and then
print out the following message:
________________________________________________________
| |
| |
| Enter your user name> |
| |
| HELLO user name |
| |
| WELCOME TO THE MPE/iX ADVANCED SKILLS COURSE!!! |
| |
| YOUR CURRENT SEARCH PATH is *** |
| |
| TODAY IS date. |
| |
| GOOD LUCK! |
| |
________________________________________________________
7. Return to the editor by entering:
EXIT
You should see the editor prompt (/).
a. Type:
LIST 80/LAST
b. Modify the source code on or near line 91 so that the
program prints out the current search path. To do this,
replace the asterisks (***) in the program's PRINTF search
path statement with:
%s
__________________________________________________________
NOTE Don't remove the single quotes, however.
__________________________________________________________
This indicates that a text string showing the value of
HPPATH will be displayed. HPPATH is a system variable that
you will learn about in the "Variables and Expressions"
module.
c. Keep the file.
8. Use the CI again to do the following:
a. compile and link the program
b. run the program
c. return to the editor
9. EXIT the editor to finish. You should see the system prompt.
If you exit the CI prematurely by entering BYE instead of EXIT,
you will terminate your session. You might also leave behind the
editor work file whose name consists of a K followed by a series
of digits.
********** End of Exercise 5-6 **********
Teaching exercise 5-7 for system managers:using the ci.
1. There is a command file in your account called HICOM. You will
edit and execute this file using the editor and the CI.
2. First, execute the command file by entering the following:
HICOM
_________________________________________________________________
NOTE An error message results. Eventually, you will have to
modify the source code and correct the errors so that the
program will run without error.
_________________________________________________________________
3. Edit the command file, make the necessary changes, and save the
file. The first line of the file needs a semicolon (;) between
USER and PROMPT:
INPUT USER;PROMPT="Enter user name> "
To make the change and save the file, follow these instructions:
EDITOR
/T HICOM
/LIST ALL
Make the necessary change to the first line of the file using the
standard editing commands (M[ODIFY], R[EPLACE], I[NSERT]).
When you are finished making changes, press Enter and keep the
file:
/K HICOM
4. Toggle back to the operating system by using the CI. Enter:
:RUN CI.PUB.SYS
or
:XEQ CI
Execute the command file as you did before. The file should
prompt you as follows, and then print out the following message:
________________________________________________________
| |
| |
| Enter your user name> |
| |
| HELLO user name |
| |
| WELCOME TO THE MPE/iX ADVANCED SKILLS COURSE!!! |
| |
| YOUR CURRENT SEARCH PATH is *** |
| |
| TODAY IS date. |
| |
| GOOD LUCK! |
| |
________________________________________________________
5. Return to the editor.
EXIT
You should see the editor prompt (/).
a. Type:
LIST ALL
b. Modify the source code on or near line 7 so that the
command file prints out the current search path. To do
this, replace the asterisks (***) in the search path ECHO
statement with:
!HPPATH
This indicates that a text string showing the value of
HPPATH is to be displayed. HPPATH is a system variable
that you will learn about in the "Variables and
Expressions" module.
c. Keep the file and then use the CI again to execute the
command file. The message that you receive should now
display a search path.
You can also execute the command file by entering
:XEQ HICOM
d. Return to the editor and then leave the editor
EXIT
to finish.
********** End of Exercise 5-7 **********
Lesson summary
1. The command interpreter (CI) provides a quick way to toggle
between the editor and the operating system.
2. The command line :RUN CI.PUB.SYS (or :XEQ CI) lets you use the CI
from the editor; EXIT returns you to the previous level of the CI
(in this lesson, usually the editor).
3. The CI is useful when writing and testing programs or command
files.
MPE/iX 5.0 Documentation