Question

I'm new in Ada and unfortunately i got stuck on a problem. Here is my code:

with Ada.Text_Io;
with Ada.Integer_Text_Io;
--use  Ada.Text_Io;
--use Ada.Integer_Text_Io;


procedure life is
type Plansza is array (Integer range <>, Integer range <>) of Integer;
File : Ada.Text_IO.File_Type;
tab : Plansza(1..4,1..4);
Filename : String := "plansza.txt";

begin
    Ada.Text_IO.Open (File => File, Mode => Ada.Text_IO.In_File, Name => Filename);
    for x in 1..4 loop
        for y in 1..4 loop
            Ada.Text_IO.Get ( File => File, Item => Plansza(x,y) );
        end loop;
    end loop;
    for x in 1..4 loop
        for y in 1..4 loop
            Ada.Text_IO.Put (Item => Plansza(x,y));
        end loop;
        New_Line;
    end loop;

end life;

End this is what i get:

life.adb:14:17: "Set_Output" is not visible

life.adb:14:17: non-visible declaration at a-textio.ads:114

life.adb:18:44: no candidate interpretations match the actuals:

life.adb:18:73: argument of type conversion must be single expression

life.adb:18:73: ==> in call to "Get" at a-textio.ads:239

life.adb:18:73: ==> in call to "Get" at a-textio.ads:205

life.adb:23:44: no candidate interpretations match the actuals:

life.adb:23:44: missing argument for parameter "File" in call to "put" declared at a-textio.ads:241

life.adb:23:44: missing argument for parameter "File" in call to "put" declared at a-textio.ads:207

life.adb:23:58: argument of type conversion must be single expression

life.adb:23:58: ==> in call to "Put" at a-textio.ads:242

life.adb:23:58: ==> in call to "Put" at a-textio.ads:208

life.adb:25:25: "New_Line" is not visible

life.adb:25:25: non-visible declaration at a-textio.ads:166

life.adb:25:25: non-visible declaration at a-textio.ads:165

gnatmake: "life.adb" compilation error

I don't know where this errors come from, especially one "non-visible declaration at a-textio.ads", by these about parameters also.

Was it helpful?

Solution

It looks as though the file you posted is not the file you are compiling (there is no Set_Output call so you're on your own with that one).

However...

Get and Put are overloaded with different versions, NONE of which match the versions you are asking for.

To Get and Put integers, you want the Get and Put from Ada.Integer_Text_Io not Ada.Text_Io. You have With clauses for both of these, but then you are explicitly calling the Text_IO ones, which cannot operate on integers.

You are Getting from a file and Putting to the console; if that's what you intended, that's OK.

To make "New_Line" visible, either uncomment the Use clause, or better, explicitly state WHICH New_Line you want, e.g. Ada.Text_IO.New_Line. The (missing) Set_Output error is probably similar. These are all easy to resolve once you see the pattern.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top