|
|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: S T
Length: 21042 (0x5232)
Types: TextFile
Names: »SCRIPT_TEXT_SAMPLE«
└─⟦180fe333a⟧ Bits:30000405 8mm tape, Rational 1000, SW CATALOG, 10_20_0
└─⟦180fe333a⟧ Bits:30000537 8mm tape, Rational 1000, SW Catalog 10_20_0
└─⟦5cb1d1d7f⟧ »DATA«
└─⟦3b1ee7bd8⟧
└─⟦this⟧
;.;
.;.
Creating Ada Programs
.;.
;.;
SCRIPT_1: Creating Ada Programs
Description:
Introduces the steps in writing programs in libraries;
introduces syntactic completion, semantic checking, and simple
I/O; and explores moving the program between states.
The program prints a message in the standard output window using
Text_Io. The program is built in a world in your home world.
;.;
Part 1. Steps 1 through 3 set up for program entry.
;.;
Step 1. Locate and go to your home world by pressing [Home Library].
;.;
Step 2. Locate and go to the Experiment world in your home world.
;.;
Step 3. Create a workspace for the program unit by pressing [Create
Ada].
A new window appears with a comp_unit prompt in which to enter
the program unit.
Notice the banner of the new window. Note the class of object
being created, Ada, and its object state, source.
;.;
Part 2. Steps 4 through 13 enter the program and make it executable.
;.;
Step 4. Make sure the cursor is on the comp_unit prompt in the new
window. Enter the following procedure declaration at the
prompt:
procedure hello is
and complete the syntax of the subprogram fragment by pressing
[Format].
Notice that the begin, a statement prompt, and the end Hello;
are automatically added. Also notice that capitalization has
been changed and indentation automatically provided.
;.;
Step 5. Move to the statement prompt by pressing [Next Item].
;.;
Step 6. Enter the following statement at the statement prompt:
text_io.put_line("Hello World
and format by pressing [Format].
Notice that the double quote, parenthesis, and semicolon are
automatically added to the end of the statement.
;.;
Step 7. Check for semantic errors by pressing [Semanticize].
Errors are indicated by underlines and a message displayed in
the Message window.
Notice that a temporary name for the Ada unit has appeared in
the Experiment world. The form of the name is _Ada_#_, where #
is some number.
;.;
Step 8. Obtain more information about the errors by pressing [Explain].
Additional error explanations are displayed in the Message
window.
;.;
Step 9. Repair the error by adding the context clause to the program
before the procedure reserved word. Move the cursor to the line
that contains the procedure by pressing [Image] - [Beg_Of].
;.;
Step 10. Enter the context clause:
with text_io;
and format.
;.;
Step 11. Again check for semantic errors by pressing [Semanticize].
;.;
Step 12. Promote the program to the installed state by pressing
[Promote].
A message that the unit has been installed appears in the
Message window. The banner indicates the name of the unit
and the object state, installed. The banner also displays a
running flag while the command is executing.
In the world, the temporary name is replaced by the actual
subprogram name for the specification and body.
;.;
Step 13. Promote the program to the coded state by pressing [Promote].
A message that the unit has been coded appears in the Message
window. The banner of the window displaying the Ada unit
indicates the new object state.
;.;
Part 3. Steps 14 through 18 execute the program.
;.;
Step 14. Return to the Experiment world by pressing [Enclosing].
;.;
Step 15. Open a Command window off the Experiment world by pressing
[Create Command].
;.;
Step 16. Enter the following statement in the Command window:
hello
;.;
Step 17. Execute the new program by pressing [Promote].
The Environment links, loads, and elaborates all units of
your program and then executes the program. Notice that the
statement you typed is now reverse video and has become a
"prompt".
A new window, called the I/O window, appears on the terminal
screen. Your message appears in this window.
The window is the standard input/output window used for the
Standard_Input and Standard_Output files defined in the Text_Io
package. The banner of this window gives the job name and
denotes it as a text object.
;.;
Step 18. You're done. Return to the script menu by pressing [F2].
;.;
;.;
.;.
Testing Ada Programs
.;.
;.;
SCRIPT_2: Testing Ada Programs
Description:
Introduces the use of Command windows for rapidly testing small
programs.
The script uses the Hello program created in ``Creating Ada
Programs.''
;.;
Part 1. Steps 1 through 6 set up a Command window for program entry.
;.;
Step 1. Locate your home world by pressing [Home Library]
;.;
Step 2. Locate and go to the Experiment world in your home world.
;.;
Step 3. Create or return to a Command window by pressing [Create
Command].
;.;
Step 4. Expand the Command window by pressing [Window] - [!] twice to
provide sufficient space to enter the test program.
;.;
Step 5. Go to the beginning of the Command window to see the entire
contents by pressing [Image] - [Begin Of].
;.;
Step 6. Move to the statement prompt by pressing [Next Item].
;.;
Part 2. Steps 7 through 15 expand the Hello program to print the message
repeatedly to illustrate how programs can be tested rapidly in
Command windows.
;.;
Step 7. Enter the program name:
hello
and format.
;.;
Step 8. Place an outer loop statement around the program name by
entering the following code before the subprogram call to
Hello;. Move the cursor to the beginning of the line by
pressing [Beg_Of].
;.;
Step 9. Enter the statements:
while count<5
count:=count+1;
and format.
Notice that the end loop and indentation are automatically
supplied.
;.;
Step 10. Check for semantic errors by pressing [Semanticize].
Errors are indicated by underlines and a message displayed in
the Message window.
;.;
Step 11. Display more information about the error in the Message window
by pressing [Explain].
Notice that formatting, semanticizing, and error indication and
handling are the same for Command windows as for Ada units in
libraries.
;.;
Step 12. Repair the error by introducing an additional declaration
before the begin reserved word. Move the cursor to that line
and press [Beg_Of].
;.;
Step 13. Enter the declaration:
count:natural:=0;
and format.
;.;
Step 14. Again check for semantic errors by pressing [Semanticize]. No
errors should exist.
;.;
Step 15. Reexecute the command procedure by pressing [Promote]. The
Hello World message appears five times in the I/O window
following the job name between lines of dashes to separate
previous results.
;.;
Part 3. Steps 16 through 21 illustrate how test programs can be changed
rapidly in Command windows.
;.;
Step 16. Return to the Command window by pressing [Create Command].
;.;
Step 17. To change the loop count, turn the prompt off by pressing [Item
Off].
This allows you to modify the text under the prompt.
The cursor should be on the line containing the while...loop.
;.;
Step 18. Change the 5 to 10 and press [Format].
;.;
Step 19. Again check for semantic errors by pressing [Semanticize].
No errors should exist.
;.;
Step 20. Reexecute the command procedure by pressing [Promote].
The Hello World message now appears ten times in the I/O window.
;.;
Step 21. You're done. Return to the script menu by pressing [F2].
;.;
;.;
.;.
Basic Debugger Operation
.;.
;.;
SCRIPT_3: Basic Debugger Operation
Description:
Uses the Debugger to debug a simple program.
The program is the Factorial program. An existing version of
that program has a bug in it. Although the bug is simple to
find and might be obvious through observation, the Debugger
will be used.
;.;
Part 1. Steps 1 through 4 execute the program and discover its erroneous
behavior.
;.;
Step 1. Locate and go to your home world.
;.;
Step 2. Locate and go to the Debugging directory.
;.;
Step 3. Create a Command window.
;.;
Step 4. Enter the following command and promote it:
debug_factorial(5 [Promote]
The Environment creates an I/O window, if it does not already
exist, and prints the answer, 16, in the window. The answer
should be 120, not 16.
;.;
Part 2. Steps 5 through 21 execute the program with the Debugger and
isolate the program error.
;.;
Step 5. Return to the Command window that invoked the Debug_Factorial
program.
;.;
Step 6. Invoke the Debugger with the program by pressing
[Meta][Promote].
The Debugger window appears. The program has not begun
execution.
;.;
Step 7. Run the program two steps by pressing [Run] twice.
This positions the Debugger to the start of your program.
The Environment displays the program in a window where the
statement or declaration to be executed next is highlighted
(selected).
The Debugger is currently about to elaborate the first
declaration of your program.
;.;
Step 8. Prepare to set a breakpoint at the second statement (this
statement begins with The_Result). Move the cursor to the
second statement and press [Object] - [<] repeatedly until the
entire statement is selected.
;.;
Step 9. Create a breakpoint by pressing [Break].
A message indicating the breakpoint number and location is
displayed in the Debugger window.
This breakpoint allows you to interrogate the actions of the
program each time through the loop.
;.;
Step 10. Execute the program by pressing [Execute].
The program stops at the breakpoint. A message indicating the
breakpoint number and location is displayed in the Debugger
window. The second statement in the program is still selected.
This is the first time through the loop. The program has not
yet executed the selected statement.
;.;
Step 11. Prepare to display the value of I. Select the occurrence of
I in the for statement by moving the cursor to I and pressing
[Object] - [<].
;.;
Step 12. Display the value of the object by pressing [Put].
The value is displayed in the Debugger window. It should be 1,
because this is the first time through the loop.
;.;
Step 13. To display the value of The_Result, select the occurrence of
The_Result that is on the left side of the assignment statement.
;.;
Step 14. Display the value of the object by pressing [Put].
The value is displayed in the Debugger window. It should also
be 1. This is the initial value, because the statement in the
loop has not yet been executed.
;.;
Step 15. Execute the program again by pressing [Execute].
The program executes until the breakpoint at the second
statement is reached. The window displaying the program unit
has the statement selected.
;.;
Step 16. Display the value of I.
The value is displayed in the Debugger window. It should be 2,
because this is the second time through the loop.
;.;
Step 17. Display the value of The_Result.
The value 2 for The_Result is displayed in the Debugger window.
;.;
Step 18. Display the next source statement to be executed by pressing
[Show Source]. The Debugger shows that it will next execute
statement 2. The program thus has executed this statement only
once. The value of The_Result should be 1.
Notice that statement 2 sets The_Result to The_Result plus
I. This is wrong. The correct algorithm should be to set
The_Result to The_Result times I.
;.;
Step 19. You could now use the standard Environment facilities to modify
the unit. You will learn how to use these facilities in the
next section.
;.;
Step 20. You're done! Return to the script menu by pressing [F2].
;.;
;.;
.;.
Modifying Ada Programs: Adding Statements
.;.
;.;
SCRIPT_4: Modifying Ada Programs: Adding Statements
Description:
Provides an example of how to make incremental changes to the
algorithm of a subprogram in a package body. This example
shows how to make such a change by adding statements to existing
subprograms.
The program used to make the changes is called
Baseball_Statistics. It is designed to calculate individual
and team batting statistics. It prompts for input about players
(at bats, hits, runs batted in) and then calculates and displays
batting percentages and team totals.
;.;
The program is built from these packages: Baseball,
Data_Inputter, and Formatter. These are used in the main
procedure called Baseball_Statistics.
The required change is in package Formatter. It is desired that
the team totals, printed at the bottom of the output from the
program, be separated by a line of dashes. We will add only the
first dashed line in the script.
This type of change does not alter or remove any existing
statements. It merely adds statements when printing the team
totals. These changes demonstrate the incremental compilation
capability of the Environment.
;.;
Part 1. Steps 1 through 3 find package Formatter, where the changes need
to be made.
;.;
Step 1. Locate and go to your home world.
;.;
Step 2. Locate and go to the world called Baseball_System in your home
world.
;.;
Step 3. Locate and go to the body of package Formatter in
Baseball_System.
The body will be the second occurrence of Formatter in the
Baseball_System world.
;.;
Part 2. Steps 4 through 10 make the first necessary change to the
package.
;.;
Step 4. Demote the Formatter package body to the installed state by
pressing [Install Unit].
The installed state allows incremental additions or changes
without requiring the recompilation of other dependent units.
;.;
Step 5. Find the procedure Print_Team_Stats in the package.
;.;
Step 6. Move to the beginning of the first statement in the procedure.
;.;
Step 7. Create an insertion window for the new statement by pressing
[Object] - [I].
The Environment creates an insertion window in the top half of
the window displaying Formatter. A temporary name is placed in
the library under the body of Formatter.
;.;
Step 8. At the statement prompt in the new window, enter:
tio.put_line
("------------------------------"&
"------------------------------
and format.
(There are 30 dashes on each line. Hint: Use the numeric
keypad.)
;.;
Step 9. Semanticize the statement by pressing [Semanticize].
This checks to make sure you will be able to add the statement
to the program. There should be no errors.
;.;
Step 10. Promote the statement by pressing [Promote].
Notice that the insertion window disappears and the new
statement replaces the prompt in the subprogram. The temporary
name is removed from the library.
;.;
Part 3. Steps 11 through 14 put the program back together again.
;.;
Step 11. Promote the body of Formatter to the coded state for execution
by pressing [Promote].
;.;
Step 12. Locate and go to the Baseball_System world by pressing
[Enclosing].
;.;
Step 13. Create a Command window, enter Baseball_Statistics, and execute
the program to verify the effect of the changes by pressing
[Promote].
;.;
Step 14. You're done! Return to the script menu by pressing [F2].
;.;
;.;
.;.
Modifying Ada Programs: Changing Statements
.;.
;.;
SCRIPT_5: Modifying Ada Programs: Changing Statements
Description:
Provides an example of how to change incrementally the
algorithm of a subprogram in a package body. This example
shows how to make such a modification by changing statements
that already exist in subprograms.
The program used to make the changes is called
Baseball_Statistics. It is designed to calculate individual
and team batting statistics. It prompts for input about players
(at bats, hits, runs batted in) and then calculates and displays
batting percentages and team totals.
;.;
The program is built from these packages: Baseball,
Data_Inputter, and Formatter. These are used in the main
procedure called Baseball_Statistics.
The required change is in package Formatter of the Baseball
program. It is desired that the columns of numbers in the
output be formatted with more space between the columns so that
they align with the headers above them. We will fix only the
first column in the script.
This type of change requires that existing I/O statements in
package Formatter be changed.
;.;
Part 1. Step 1 finds the package that needs to be changed.
;.;
Step 1. Locate and go to the body of package Formatter in
Baseball_System.
The body will be the second occurrence of Formatter in the
Baseball_ System world.
;.;
Part 2. Steps 2 through 7 make the first necessary change to the
package.
;.;
Step 2. Demote the package body to the installed state by pressing
[Install Unit].
The installed state allows incremental additions or changes
without requiring the recompilation of other units.
;.;
Step 3. Find the Put_Statistic_Values procedure in the package. This
is the procedure that must be changed.
;.;
Step 4. Locate and select the first statement in the procedure (the one
with At_Bat) by moving the cursor to that line and pressing
[Object] - [<] repeatedly until the entire statement is
selected.
;.;
Step 5. Edit that statement by pressing [Edit].
The Environment replaces that statement in the procedure with
a statement prompt and creates a window in which to edit the
statement. A temporary name is placed in the library under the
body of Formatter.
;.;
Step 6. Change the value 5 to 8.
This is the field width for the value. It makes the column
eight characters wide instead of five.
;.;
Step 7. Promote the statement by pressing [Promote].
The window disappears and the changed statement reappears
in the procedure. The temporary name in the Baseball_System
library is removed.
;.;
Part 3. Steps 8 through 10 put the program back together again.
;.;
Step 8. Promote the entire package body to the coded state by pressing
[Promote].
;.;
Step 9. Create a Command window, enter Baseball_Statistics, and execute
the program to verify the changes by pressing [Promote].
;.;
Step 10. You're done! Return to the script menu by pressing [F2].
;.;