Figure 22.
Usual_Solution.
--------------------------------------------------------
-- The usual solution is to avoid the problem
-- by handling the exception where it occurs.
with SCROLL_TERMINAL; use SCROLL_TERMINAL;
procedure Usual_Solution is
NAME : string(1..30);
ADDRESS : string(1..40);
CITY_STATE_ZIP : string(1..40);
procedure Get_Name(NAME : out string) is
begin
get("What is your Name? ", NAME);
exception
when NEEDS_HELP =>
put_line("Don't you even know your own name?");
Get_Name(NAME);
end Get_Name;
procedure Get_Address(ADDRESS : out string) is
begin
get("What is your Address? ", ADDRESS);
exception
when NEEDS_HELP =>
put_line("What is your street or P.O Box?");
Get_Address(ADDRESS);
end Get_Address;
procedure Get_City(CITY : out string) is
begin
get("Where do you Live? ", CITY);
exception
when NEEDS_HELP =>
put_line("Please enter City, State, and Zip code.");
Get_City(CITY);
end Get_City;
begin
Get_Name(NAME);
Get_Address(ADDRESS);
Get_City(CITY_STATE_ZIP);
SCROLL_TERMINAL.new_line(10);
SCROLL_TERMINAL.put_line
("NAME = " & NAME);
SCROLL_TERMINAL.put_line
("ADDRESS = " & ADDRESS);
SCROLL_TERMINAL.put_line
("CITY = " & CITY_STATE_ZIP);
end Usual_Solution;