| COP2250 | CGS4825 | COP4226 | COP2210 | CDA4101 | UNIX | HOME |
|
||||||
If you do not have access to serss0, you can log onto serss1, and then issue
rlogin serss0
this will get you onto serss0. When you log off, you will need to log off serss0, and then serss1.
You must set up your .cshrc file in order to run Ada programs on UNIX. There are two ways to do this:
cp ~downeyt/cbin/ada.cshrc .cshrc
then proceed with executing your .cshrc.
~downeyt/cbin/ada.include
The easiest way to add this to your .cshrc file is to call the emacs editor
emacs .cshrc
Then move the cursor to the end of the file (this is very important) and issue the command
CTRL-X I ~downeyt/cbin/ada.include
then save your changes and exit
CTRL-X CTRL-S CTRL-X CTRL-C
and continuing with executing your .cshrc.
Once you have set this up then you must be sure to re-execute your .cshrc file. There are two ways to do this
set path = () source .cshrc
Now that you have set up Ada for your UNIX account, you can run an Ada program. These are the steps you would follow:
gcc -c prog.adb
gnatbl -o prog prog.ali
prog
cat prog.adb
When you test for End_Of_File in an Ada program, UNIX is looking for the CRTL-D key. So, if you are using a while not End_Of_File loop and reading input from the terminal, the user can terminate the loop by entering CTRL-D.
Be careful not to enter CTRL-Z, since this will stop your program, not the loop. When you press CTRL-Z on a UNIX system, the current job is interupted (not terminated) and placed in the background. To recover from such an error, you can type the fg command to bring the job back to the foreground. Then you can press CTRL-D to terminate the loop.
I have placed a file called ada.emacs in my cbin directory. It contains the LISP code needed to use Ada mode in emacs. Ada mode will automatically format your source file as you type. It will also check that your end statements match the statement that you are finishing. Just remember to use CTRL-J at the end of a line, instead of the RETURN key. There are two methods for setting this up:
cp ~downeyt/cbin/ada.emacs .emacs
CTRL-X I ~downeyt/cbin/ada.emacs
I have also included some commented code in the ada.emacs file. This is for a function that allows you to abbreviate the words procedure, function, and package with pr, fu, and pa respectively. In order to implement this, you must copy the file prog.abrv.elc from my cbin directory into your root directory, then edit the .emacs file and remove the semicolons from the definition of the function.
First, you must download Ada95 for DOS. Once you have done this, and set up your DOS machine for Ada, these are the steps you would follow to run a program:
gcc -c prog.adb
gnatbl -o prog.exe prog.ali
prog
type prog.adb
If you haven't downloaded Adacaps, then you will need to in order to create the listing that I want. In the Adacaps zip file, there is another zip file called Script.zip. Unzip this, and you will have a file called script.com. You will use this to echo all the output to your screen into a file. It is very similar to the UNIX script command.
When handing in an assignment, I would like to see a copy of all the output on your terminal when you compile, link, and run the program. This listing should include all the input and output to the program as well as a listing of the complete program. The command to do this is script.
script
When you run script, a new process is created. All information that is displayed on the terminal in this process is also copied to a file called typescri in your original process. Once inside the subprocess, you would issue the commands to compile, link, and run the Ada program, then you would use the type command to display the contents of the program source files. When you are done, you press CRTL-Z to exit the subprocess, then you can print the typescri file using print or by calling up a text editor and printing the file.
The default file is typescri, but it is possible to use any file by including it in the script command.
script -f file
Then you would print file instead of typescri.
When you test for End_Of_File in an Ada program, DOS is looking for the CRTL-Z key. So, if you are using a while not End_Of_File loop and reading input from the terminal, the user can terminate the loop by entering CTRL-Z.