|
|
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: B T
Length: 4042 (0xfca)
Types: TextFile
Names: »B«
└─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11
└─⟦129cab021⟧ »DATA«
└─⟦this⟧
package body Bounded_Strings is
function Power (Of_Number, N : Integer) return Integer is
Result : Integer := 1;
begin
if N = 0 then
return 1;
else
for K in 1 .. N loop
Result := Result * Of_Number;
end loop;
return Result;
end if;
exception
when Numeric_Error =>
return 0;
end Power;
function To_Number (The_String : in Variable_Strings; In_Base : in Positive)
return Integer is
I : Integer := The_String.The_Length;
Aux : Integer;
Result : Integer := 0;
begin
while I >= 1 loop
if The_String.The_Content (I) in '0' .. '9' then
Aux := Character'Pos (The_String.The_Content (I)) - 48;
else
Aux := Character'Pos (The_String.The_Content (I)) - 55;
end if;
Result := Result + Aux * Power (In_Base, The_String.The_Length - I);
I := I - 1;
end loop;
return Result;
exception
when Numeric_Error =>
return 0;
end To_Number;
procedure Free (The_String : in out Variable_Strings) is
begin
The_String.The_Length := Void;
end Free;
procedure Append (To_The_String : in out Variable_Strings;
The_Char : in Character) is
begin
if (To_The_String.The_Length < To_The_String.The_Content'Last) then
To_The_String.The_Length := To_The_String.The_Length + 1;
To_The_String.The_Content (To_The_String.The_Length) := The_Char;
end if;
end Append;
procedure Set (The_String : in out Variable_Strings;
With_String : in String) is
begin
if (With_String'Last <= The_String.The_Content'Last) then
The_String.The_Length := With_String'Length;
The_String.The_Content (With_String'Range) :=
With_String (With_String'Range);
else
The_String.The_Length := The_String.The_Content'Length;
The_String.The_Content (The_String.The_Content'Range) :=
With_String (The_String.The_Content'Range);
end if;
end Set;
procedure Affect (The_String : in out Variable_Strings;
With_String : in Variable_Strings) is
begin
if (With_String.The_Content'Last <= The_String.The_Content'Last) then
The_String.The_Length := With_String.The_Length;
The_String.The_Content (With_String.The_Content'Range) :=
With_String.The_Content (With_String.The_Content'Range);
else
The_String.The_Length := The_String.The_Content'Length;
The_String.The_Content (The_String.The_Content'Range) :=
With_String.The_Content (The_String.The_Content'Range);
end if;
end Affect;
function Length (From_The_String : in Variable_Strings) return Natural is
begin
return From_The_String.The_Length;
end Length;
function Image (From_The_String : in Variable_Strings) return String is
begin
return (From_The_String.The_Content (1 .. From_The_String.The_Length));
end Image;
function Upper_Case_Image
(From_The_String : in Variable_Strings) return String is
Chain : String (1 .. From_The_String.The_Length) :=
Bounded_Strings.Image (From_The_String);
begin
for I in Chain'Range loop
if (Chain (I) > 'Z') then
Chain (I) := Character'Val (Character'Pos (Chain (I)) - 32);
end if;
end loop;
return Chain;
end Upper_Case_Image;
function Is_Equal (Left, Right : in Bounded_Strings.Variable_Strings)
return Boolean is
begin
return ((Left.The_Length = Right.The_Length) and then
(Left.The_Content (1 .. Left.The_Length) =
Right.The_Content (1 .. Right.The_Length)));
end Is_Equal;
end Bounded_Strings;