The thing about plain String
in Ada is that a particular string, like your File_Name
, has to be fixed-length; but different Strings can be of different length.
You can write
S1 : String := "1234";
S2 : String := "12345";
in which case S1 is of length 4, and assignments to it have to be of length 4. You can write
S1 := "abcd";
but if you try to write
S1 := "pqrst";
or
S1 := S2;
you will get a Constraint_Error
.
In the case of String parameters to subprograms, like your Open_Data
, the String parameter Name
takes on the length -- and of course the value! of the actual parameter in the call. So you can say
Open_Data (X_File, "x.dat");
Open_Data (Y_File, "a_very_long_name.dat");
You were having problems earlier with
procedure Open_Data(File : in out Seq_Float_IO.File_Type;
Name : in String) is
begin
Seq_Float_IO.Open (File => File,
Mode => Seq_Float_IO.Append_File,
Name => ????);
I'm reluctant to just tell you the answer, so -- consider the File => File
part. The first File
is the name of the formal parameter of Seq_Float_IO.Open
and the second File
is what is to be passed, in this case Open_Data
's File
parameter.
It might help if I point out that I could have written the calls above as
Open_Data (File => X_File, Name => "x.dat");
Open_Data (File => Y_File, Name => "a_very_long_name.dat");