Figure 19.
ASCII_UTILITIES demo.
------------------------------------------------------
with ASCII_UTILITIES, TEXT_IO;
procedure ASCII_UTILITIES_Demo is
type Values is (NOTHING, A_PAIR, TWO_PAIR,
THREE_OF_A_KIND, A_STRAIGHT, A_FLUSH,
A_FULL_HOUSE, FOUR_OF_A_KIND,
A_STRAIGHT_FLUSH, A_ROYAL_FLUSH);
S : string(1..16);
begin
TEXT_IO.put_line("Possible poker hands are:");
for i in Values loop
-- Make all values 16 character strings,
-- padding with nulls if necessary.
ASCII_UTILITIES.String_Copy
(FROM => Values'IMAGE(i),
TO => S,
FILL => ASCII.NUL);
-- Convert all character to lower case.
S := ASCII_UTILITIES.Lower_Case(S);
-- Change underlines to spaces.
S := ASCII_UTILITIES.Change(S);
-- Capitalize the first letter.
S(1) := ASCII_UTILITIES.Upper_Case(S(1));
-- indent and print it
TEXT_IO.put_line(" " & S & ',');
end loop;
end ASCII_UTILITIES_Demo;
--------------------------------
When directed to a printer, the output looks
like this:
Possible poker hands are:
Nothing,
A pair,
Two pair,
Three of a kind,
A straight,
A flush,
A full house,
Four of a kind,
A straight flush,
A royal flush,