I'm a bit of a beginner when it comes to Ada, and I'm trying to declare and use an array of strings of different lengths.
Using Ada'83 I can declare an array of variable length string constants as follows (example taken from the Ada FAQ)
type table is access String;
TESTS : constant array (Positive range 1..3) of table
:= ( 1 => new String'("One"),
2 => new String'("Two"),
3 => new String'("Three")
);
However much to my frustration even though the result appears to be an array of character arrays they don't behave as strings. When I try to compile the following code I get an error message 'Inconsistency detected during overload resolution [LRM 8.7]'
for COUNT in TESTS'Range loop
Put(TESTS(COUNT));
New_Line;
end loop;
However, I can print out the content of each of the 'strings' using the following code.
for COUNT in TEST'Range loop
for COUNTER in TEST(COUNT)'Range loop
Put(TEST(COUNT)(COUNTER));
end loop;
New_Line;
end loop;
Unfortunately I want to use the values to test some code that takes a string as a parameter, so this doesn't really help...
Is there a way to be to iterate over an array of string constants of varying length in Ada'83, or to convert the character arrays into strings of varying length.
Thanks
No, this isn't homework, and yes, I know I'm using an ancient compiler!