From: Per Sandberg <per.sandberg@sandat.dyndns.org>
Subject: Re: gnatmake error I don't understand
Date: Fri, 4 Apr 2014 06:14:39 +0200
Date: 2014-04-04T06:14:39+02:00 [thread overview]
Message-ID: <20140404061439.30bcff62@lufsen.sandat.dyndns.org> (raw)
In-Reply-To: g5vrj9h4gs93iuojnlqeshqp78urlullkg@4ax.com
On Thu, 03 Apr 2014 20:35:18 -0400
agent@drrob1.com wrote:
The attribute "Main" is a file-name so it shall be:
for main use ("habits.adb");
and not:
for main use ("Habits");
/Per
> I typed the following code from a recent issue of Linux Format
>
> texthabits.ads
> with Ada.Text_IO, Ada.Strings.Unbounded,
> Ada.Strings.Unbounded.Text_IO, Ada.Integer_Text_IO;
> use Ada.Text_IO, Ada.Strings.Unbounded,
> Ada.Strings.Unbounded.Text_IO, Ada.Integer_Text_IO;
>
> -- REVISION HISTORY
> -- ================
> -- 31 Mar 14 -- Extracted from LinuxFormat LXF 181 coding article
>
> Package texthabits is
>
> PROCEDURE CreateOrOpen (File: in out File_Type; Name: in String; Form:
> in String := "");
>
> Procedure OpenOrCreateDataFile(File : in out File_Type; Name : in
> String);
>
> Procedure ReadAndDisplayDatafile(File : in out File_Type; Name :
> String);
>
> Procedure Habits ;
>
> END texthabits;
>
> -----------------------------------------------------------------------------------------
> texthabits.adb
> with Ada.Text_IO, Ada.Strings.Unbounded,
> Ada.Strings.Unbounded.Text_IO, Ada.Integer_Text_IO, Ada.Calendar,
> Ada.Directories;
> use Ada.Text_IO, Ada.Strings.Unbounded,
> Ada.Strings.Unbounded.Text_IO, Ada.Integer_Text_IO, Ada.Calendar,
> Ada.Directories;
>
> -- REVISION HISTORY
> -- ================
> -- 31 Mar 14 -- Extracted from LinuxFormat LXF 181 coding article
>
>
> Package body texthabits is
> habit : Unbounded_String;
> filehandle : File_Type;
> HabitFileName : String(1..13);
> ctr : Natural := 1;
>
> PROCEDURE CreateOrOpen (File: in out File_Type; Name: in String; Form:
> in String := "") is
> BEGIN
> Open(File, Append_File, Name, Form);
> EXCEPTION
> WHEN Ada.Text_IO.Name_Error =>
> Create(File, Out_File, Name, Form); -- If must create file, then
> append_file does not make sense, even if desired.
> END CreateOrOpen;
>
> Procedure OpenOrCreateDataFile(File : in out File_Type; Name : in
> String) is
> Begin
> Open(File, Append_File, Name);
> Exception
> when Ada.Text_IO.Name_Error => Create(File => File, Mode =>
> Append_File, Name => Name);
> End OpenOrCreateDataFile;
>
> Procedure ReadAndDisplayDatafile(File : in out File_Type; Name :
> String) is
> buffer : String(1..100);
> length : Natural;
> Begin
> IF EXISTS(Name) THEN
> Open(File => File, Mode => In_File, Name => Name);
> While not End_Of_File(File => File) loop
> Get_Line(File => File, item => buffer, last => Length);
> Put_Line(buffer(1..length));
> end loop;
> Close(File);
> END IF; -- if exists
> End ReadAndDisplayDatafile;
>
>
> Procedure Habits is
> Begin
> HabitFileName := "habitfile.txt";
> ReadAndDisplayDatafile(filehandle, HabitFileName); -- for input. Do
> nothing if file does not exist.
> OpenOrCreateDataFile(filehandle, HabitFileName); -- for output
> LOOP
> Put(" Enter a new habit, quit or exit: ");
> habit := Get_Line;
> exit when (CAP(To_STRING(Head(Habit,4))) = "QUIT") OR
> (CAP(to_string(Head(Habit,4))) = "EXIT") ;
> Put_Line(filehandle,Habit);
> ctr := ctr + 1;
> END LOOP;
> Close(filehandle);
> Put(" You entered and saved ");
> Put(ctr,3);
> Put_Line(" new habits.");
> End Habits;
>
> END texthabits;
> ---------------------------------------------------------------------------------
> texthabits.gpr
> project texthabits is
> for Source_Files use ("texthabits.adb", "texthabits.ads",
> "tokenizea.ads", "tokenizea.adb");
> for Source_Dirs use (".", "./**");
> for Main use ("Habits");
>
> package Builder is
> for Default_Switches ("Ada")
> use ("-g");
> end Builder;
>
> package Compiler is
> for Default_Switches ("Ada")
> use ("-fstack-check",
> "-gnatVa",
> "-g",
> "-gnato",
> "-gnatf",
> "-gnatwu",
> "-gnat2012");
> end Compiler;
>
> end texthabits;
>
> ------------------------------------------------------------------------------
> Ubuntu 12.04 amd64 version
>
> gnatmake -Ptexthabits
>
> gnatmake: "Habits" is not a source of project texthabits.
>
> I don't understand the error or what to do about it.
>
> Thanks,
> Rob Solomon
>
next prev parent reply other threads:[~2014-04-04 4:14 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-04 0:35 gnatmake error I don't understand agent
2014-04-04 0:44 ` agent
2014-04-04 4:14 ` Per Sandberg [this message]
2014-04-04 7:37 ` Simon Wright
2014-04-04 7:50 ` Simon Wright
2014-04-04 13:35 ` Tero Koskinen
2014-04-04 13:41 ` Robert A Duff
2014-04-04 17:14 ` Simon Wright
2014-04-04 17:45 ` Adam Beneschan
2014-04-05 0:35 ` Robert A Duff
2014-04-05 0:52 ` Adam Beneschan
2014-04-04 21:27 ` Randy Brukardt
2014-04-04 18:48 ` Stephen Leake
2014-04-04 19:25 ` Simon Wright
2014-04-04 20:02 ` drrob106
2014-04-04 20:43 ` Shark8
2014-04-04 22:58 ` Jeffrey Carter
2014-04-04 20:48 ` Simon Wright
2014-04-05 0:33 ` Robert A Duff
2014-04-05 8:17 ` Georg Bauhaus
2014-04-05 13:28 ` Simon Wright
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox