Download The Big Book of Linux Ada Programming

Transcript
Big Online Book of Linux Ada Programming - 10 An Introduction to Ada
-- this program demonstrates more advanced input/output
i : integer := 5; -- this variable contains an integer number
-- i initially has the value of 5
s : string(1..20); -- this variable contains a 20 character string
len : natural;
begin
Put_Line( "This program displays information on the screen" );
Put_Line( "and reads information from the keyboard");
New_Line;
Put_Line( "'img returns the string representation of a variable's" );
Put_Line( "value. The value i is" & i'img);
New_Line;
s := "...................."; -- set s to 20 periods
Put_Line(
Put_Line(
Put_Line(
Get_Line(
"The variable s is " & s);
"Get_Line reads a string from the keyboard" );
"Type in a message up to 20 characters and press Enter:" );
s, len );
Put_Line( "After Get_Line copies your message to s, s is now '" & s & "'" );
Put_Line( "The message is" & len'img & " characters long." );
Put_Line( "The characters after your message remain unchanged." );
end basicio2;
This program displays information on the screen
and reads information from the keyboard
'img returns the string representation of a variable's
value. The value i is 5
The variable s is ....................
Get_Line reads a string from the keyboard
Type in a message up to 20 characters and press Enter:
jingle bells
After Get_Line copies your message to s, s is now 'jingle bells........'
The message is 12 characters long.
The characters after your message remain unchanged.
file:///G|/Linux/http-www.vaxxine.com-pegasoft-people-html/book/10.html (8 of 29) [7/20/2001 11:33:06 AM]