-- -- Use the general stack package. -- with Gnat.Io; use Gnat.Io; with GenStack; use GenStack; with IStack; use IStack; with SStack; use SStack; procedure UseStack is -- Print the stack of integers. procedure PrintInt(S: in out Stack) is I: IntStackData; begin while not Empty(S) loop Pop(S, I); Put(IValue(I)); Put(" "); end loop; New_Line; end PrintInt; -- Print the stack of strings. procedure PrintStr(S: in out Stack) is I: StrStackData; begin while not Empty(S) loop Pop(S, I); Put_Line(SValue(I)); end loop; end PrintStr; -- Test vars. In_Int: Integer; In_String: String(1..50); I: Integer; R, S: Stack; begin -- Get some integers. loop -- Read integers, stopping at -1. Put("Enter Integers, -1 to quit > "); Get(In_Int); exit when In_Int = -1; Push(R, IDat(In_Int)); end loop; -- Print 'em, twice. S := R; PrintInt(R); PrintInt(S); -- Get some strings. Get_Line(In_String, I); New_Line; loop -- Read a string Put("Read Strings, 'stop' to quit > "); Get_Line(In_String, I); exit when In_String(1..I) = "stop"; Push(R, SDat(In_String(1..I))); end loop; S := R; New_Line; PrintStr(R); New_Line; PrintStr(S); end UseStack;