comp.lang.ada
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* Re: GNATCOLL-Mmap example
  @ 2020-01-28 18:53  6%   ` Bob Goddard
  0 siblings, 0 replies; 41+ results
From: Bob Goddard @ 2020-01-28 18:53 UTC (permalink / raw)


On Tuesday, 28 January 2020 08:25:25 UTC, Dmitry A. Kazakov  wrote:
> On 2020-01-25 22:52, Bob Goddard wrote:
> 
> > I need to map the RPi's GPIO memory addresses so that I can do what I need to do.
> 
> See files under:
> 
>     /sys/class/gpio
> 
> You can use standard Ada I/O to read and set GPIO pins. E.g.
> 
>     /sys/class/gpio/gpio/XXX/value

This was the way I started, but could not get it to read anything. It just blocks trying to read a single character. My c code works fine using the wiringPi libs.

Stephen Leake:
Mmap is used to read more than just disk files. Opening /dev/mem, or even /dev/gpiomem, is just another file.

Regardless, I got it to work. The moral of the story, is never assume example code in the library source works, or even can compile. I got it running a couple of days ago, and have since spent time banging my head against a wall.

This works, both with System.Mmap & GNATCOLL.Mmap...

with Ada.Unchecked_Conversion;
with Ada.Text_IO;
with GNATCOLL.Mmap; use GNATCOLL.Mmap;
with Ada.Strings.Unbounded;
with Ada.Strings.Unbounded.Text_IO;

procedure Mmaptest is
   package Mmap renames GNATCOLL.Mmap;

   File : Mmap.Mapped_File;
   Reg  : Mmap.Mapped_Region;
   Str  : Mmap.Str_Access;
   Offs : Mmap.File_Size := 0;
   Page : constant Mmap.File_Size := Mmap.File_Size (Mmap.Get_Page_Size);
begin
   File := Mmap.Open_Write ("/tmp/file_on_disk");
   
   while Offs < Mmap.Length (File) loop
      Mmap.Read (File, Reg, Offs, Length => Page, Mutable => False);
      Str := Mmap.Data (Reg);
      Ada.Strings.Unbounded.Text_IO.Put (Ada.Strings.Unbounded.To_Unbounded_String (
                                              Str (Integer (Offs - Mmap.Offset (Reg)) + 1 .. Mmap.Last (Reg)))
                                             );
      Offs := Offs + Page; --  Mmap.File_Size (Mmap.Last (Reg));
   end loop;
   
   Mmap.Free (Reg);
   
   if Reg /= Mmap.Invalid_Mapped_Region then
      Ada.Text_IO.Put_Line ("Mapped region still valid");
   end if;
   
   Mmap.Close (File);
   
   if File /= Mmap.Invalid_Mapped_File then
      Ada.Text_IO.Put_Line ("Mapped file still valid");
   end if;
end Mmaptest;

^ permalink raw reply	[relevance 6%]

* article on acces types and dynamic serialization in Ada (2003)
@ 2018-02-21 23:57  5% Mehdi Saada
  0 siblings, 0 replies; 41+ results
From: Mehdi Saada @ 2018-02-21 23:57 UTC (permalink / raw)


Hello everyone.
I already mailed you Simon Wright about it, but I've more info and questions, so it put it here. First the context:
I played with streams yesterday to learn more, and stumbled on something not really intuitive, at least. what means exactly Some_access_type'Write(Stream1, Some_Pointer) ?
I could figure out it's implementation defined, so you can't guess.
So that
Some_access_type'Write(stream(Stream_File), Pointer1);
...
Reset(Stream_File, IN_FILE);
Some_access_type'Read(stream(Stream_file), Pointer2);
doesn't work: reaching Pointer2.all raises "erroneous memory access", though Pointer2 isn't null.
Strange, since in my exemple, all happen in the same, hum, "scope of declaration" (apropriate term ?). Any address or whatever information the pointer is made of, should still be valid. Any pool pointed at still exists.
Doesn't feel like a "sane" legal behavior. I also saw a "normal" record object with a pool-specific pointer like this one
type FOO is record
  ...
  BAR: access INTEGER := new INTEGER'(15);
end record;
serializes well, I can read Bar.all. Funny, but where the difference since (according to Ada wikibook) a priori the default 'Write is called for each record component ?

Then I found today that https://infoscience.epfl.ch/record/54724/files/IC_TECH_REPORT_200363.pdf : Automatic Serialization of Dynamic Structures in Ada Technical Report

I was surprised I could read and understand it all with some concentration. And a bit proud, to be honnest ! I would have thought it to be like Chinese at my level.
It was 13 years ago, but I couldn't find a more recent papier on the subject of dynamic serialization, nor has new Dynamic_Stream aspects/attributes been added since then. I didn't read anything either in the stream or access types related sections.

I tried more, but can't write well yet that more complicated exemple:
with Ada.Streams.Stream_IO, Ada.Strings.Unbounded.Text_IO, Ada.Text_IO;
use Ada.Streams.Stream_IO, Ada.Streams, Ada.Strings.Unbounded, Ada.Strings.Unbounded.Text_IO;
procedure Main is
   subtype TSF is File_Type;
   FILE : TSF;
   type CHAMPS;
   type ACCESS_CHAMPS is access ALL CHAMPS;
   type CHAMPS (A: ACCESS_CHAMPS) is record
      NOTE : NATURAL range 0 .. 20 := 0;
   end record;
   
   C2, C1 , C3  :  aliased CHAMPS := (A => null, note => 5); 
begin
        
   C1 := (C2'Access, 14);
   C2 := (A => C1'Access, Note => 5 ); 
   Create (FILE, Append_File, Name => "tentative.stream");
   CHAMPS'Write (Stream (FILE), C2);
   Reset (File => FILE,
	  Mode => In_File );
   CHAMPS'Read(Stream(FILE), C3);
   ada.Text_IO.Put_line (INTEGER'Image (C3.A.all.Note));
   CLOSE(FILE);
end;

raises CONSTRAINT_ERROR : main.adb:15 discriminant check failed
I read as I could about access discrimant aliasing and autoreferencing types, but visibly lack practice ;-)  
Could you help me finish that exemple ? I would be delighted to see what happens by myself, since the former exemple (Some_Access'Write and 'Read) proves interesting.

Gosh, the pleasure these things give me...

^ permalink raw reply	[relevance 5%]

* Re: gnatmake error I don't understand
  2014-04-04  0:35  6% gnatmake error I don't understand agent
@ 2014-04-04  4:14  0% ` Per Sandberg
  0 siblings, 0 replies; 41+ results
From: Per Sandberg @ 2014-04-04  4:14 UTC (permalink / raw)


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
> 


^ permalink raw reply	[relevance 0%]

* gnatmake error I don't understand
@ 2014-04-04  0:35  6% agent
  2014-04-04  4:14  0% ` Per Sandberg
  0 siblings, 1 reply; 41+ results
From: agent @ 2014-04-04  0:35 UTC (permalink / raw)


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



^ permalink raw reply	[relevance 6%]

* Re: Text parsing package
  @ 2011-03-23 11:19  6%   ` Syntax Issues
  0 siblings, 0 replies; 41+ results
From: Syntax Issues @ 2011-03-23 11:19 UTC (permalink / raw)


Thanks for posting the techniques Dmitry. I am going to try
implementing as many as I can -- I am still a fairly new programmer,
and I still have a lot to learn.
Right now it uses text_io and strings.unbounded.text_io (this is
probably bad :/) and only works with files. I tried to make it as
simple as possible with exception checking -- global booleans are set
and checked by the running program.
-- Spec
with
	Ada.Exceptions,
	Ada.Text_Io,
	Ada.Strings.Unbounded.Text_Io,
	Ada.Strings.Unbounded;
use
	Ada.Exceptions,
	Ada.Text_Io,
	Ada.Strings.Unbounded.Text_Io,
	Ada.Strings.Unbounded;
package Parsing
	is
	---------------
	-- Constants --
	---------------
		DEBUGGING_ON                  : constant Boolean          := true;
		EXCEPTION_PARSE_NOTHING       : constant String           :=
"Attempted to parse passed the end-of-file.";
		EXCEPTION_PARSE_UNOPENED_FILE : constant String           :=
"Attempted to parse an unopened file.";
		EXCEPTION_PARSE_NON_NUMBER    : constant String           := "Failed
to parse a number.";
		NULL_STRING_FIXED             : constant String           := "";
		NULL_STRING_UNBOUNDED         : constant Unbounded_String :=
To_Unbounded_String(NULL_STRING_FIXED);
	--------------
	-- Packages --
	--------------
		package Io_Integer
			is new Ada.Text_Io.Integer_Io(Integer);
		package Io_Float
			is new Ada.Text_Io.Float_Io(Float);
	---------------
	-- Variables --
	---------------
		Error_On_Recent_Operation  : Boolean          := false;
		Error_Occured_Parsing_File : Boolean          := false;
		Line                       : Unbounded_String :=
NULL_STRING_UNBOUNDED;
		File                       : File_Type;
	-----------------
	-- Subprograms --
	-----------------
		procedure Open
			(Name : in String);
			pragma Inline(Open);
		procedure Close;
			pragma Inline(Close);
		function Next_Unbounded_String
			return Unbounded_String;
		function Next_String
			return String;
			pragma Inline(Next_String);
		function Next_Integer
			return Integer;
		function Next_Float
			return Float;
	end Parsing;
--- Body
package body Parsing
	is
	--
	-- Open_File
	--
	procedure Open
		(Name : in String)
		is
		begin
			Ada.Text_Io.Open(File, In_File, Name);
			if not End_Of_File(File) then
				Line := Get_Line(File);
			end if;
		end Open;
	--
	-- Close_File
	--
	procedure Close
		is
		begin
			if Is_Open(File) then
				Ada.Text_Io.Close(File);
				Error_Occured_Parsing_File := false;
			end if;
		end Close;
	--
	-- Next_Unbounded_String
	--
	function Next_Unbounded_String
		return Unbounded_String
		is
		Result : Unbounded_String := NULL_UNBOUNDED_STRING;
		begin
			Error_On_Recent_Operation := false;
			Trim(Line, Ada.Strings.Both);
			if not Is_Open(File) then
				if DEBUGGING_ON then
					Put_Line(EXCEPTION_PARSE_UNOPENED_FILE);
				end if;
				Error_Occured_Parsing_File := true;
				Error_On_Recent_Operation  := true;
				return Result;
			end if;
			loop
				if Length(Line) /= 0 then
					for I in 1..Length(Line) loop
						if Element(Line, I) = ' ' or I = Length(Line) then
							Result := To_Unbounded_String(Slice(Line, 1, I));
							Delete(Line, 1, I);
							return Result;
						end if;
					end loop;
				else
					if End_Of_File(File) then
						if DEBUGGING_ON then
							Put_Line(EXCEPTION_PARSE_NOTHING);
						end if;
						Error_Occured_Parsing_File := true;
						Error_On_Recent_Operation  := true;
						return Result;
					end if;
					Line := Trim(Get_Line(File), Ada.Strings.Both);
				end if;
			end loop;
		end Next_Unbounded_String;
	--
	-- Next_String
	--
	function Next_String
		return String
		is
		begin
			return To_String(Next_Unbounded_String);
		end Next_String;
	--
	-- Next_Integer
	--
	function Next_Integer
		return Integer
		is
		Last   : Positive;
		Result : Integer := 0;
		begin
			Io_Integer.Get(To_String(Next_Unbounded_String), Result, Last);
			return Result;
			exception
				when Data_Error | Constraint_Error =>
					if DEBUGGING_ON then
						Put_Line(EXCEPTION_PARSE_NON_NUMBER);
					end if;
					Error_Occured_Parsing_File := true;
					Error_On_Recent_Operation  := true;
					return Result;
		end Next_Integer;
	--
	-- Next_Float
	--
	function Next_Float
		return Float
		is
		Last   : Positive;
		Result : Float := 0.0;
		begin
			Io_Float.Get(To_String(Next_Unbounded_String), Result, Last);
			return Result;
			exception
				when Data_Error | Constraint_Error =>
					if DEBUGGING_ON then
						Put_Line(EXCEPTION_PARSE_NON_NUMBER);
					end if;
					Error_Occured_Parsing_File := true;
					Error_On_Recent_Operation  := true;
					return Result;
		end Next_Float;
	end Parsing;



^ permalink raw reply	[relevance 6%]

* Re: confusion with string initialization
  @ 2010-04-17 17:42  7% ` 
  0 siblings, 0 replies; 41+ results
From:  @ 2010-04-17 17:42 UTC (permalink / raw)


brett wrote:
> I'm trying to learn Ada 2005 with GNAT ( Linux) and are having problems with string initialization using the 
> 
> bs := 20 * " ";  
> 
> construct, which always gives an error 
> 
> "universal integer expected"
> 
> As my syntax is similar to that in Ada 2005 book by Barnes
> (page 594 & 596) I'm a bit confused :-)
> Searching the ARM was of no value either !
> 
> Thanks for any input

Hey Brett,

Here's how the complete example from the excellent John Barnes book 
could look:


with Ada.Strings.Bounded;           use Ada.Strings.Bounded;
with Ada.Strings.Fixed;             use Ada.Strings.Fixed;
with Ada.Strings.Unbounded;         use Ada.Strings.Unbounded;
with Ada.Text_IO;                   use Ada.Text_IO;
with Ada.Text_IO.Bounded_IO;
with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO;

procedure String_Test is
    package Bounded_80 is new Generic_Bounded_Length (80);
    use Bounded_80;
    package Bounded_80_IO is new Bounded_IO (Bounded_80);
    use Bounded_80_IO;

    BS : Bounded_String;
    US : Unbounded_String;
    S15 : String (1 .. 15);
begin
    BS := 2 * "Bar";
    Put_Line (BS);

    US := 3 * 'A';
    Put_Line (US);

    US := 2 * US;
    Put_Line (US);

    S15 := 5 * "SOS";
    Put_Line (S15);
end String_Test;


And here's the output you should get when executing the program:

BarBar
AAA
AAAAAA
SOSSOSSOSSOSSOS

-- 
Regards,
Thomas L�cke

Email: tl at ada-dk.org
Web: http:ada-dk.org
IRC nick: ThomasLocke



^ permalink raw reply	[relevance 7%]

* Re: variable lenght strings
  @ 2004-10-22  7:38  4%     ` Martin Krischik
  0 siblings, 0 replies; 41+ results
From: Martin Krischik @ 2004-10-22  7:38 UTC (permalink / raw)


Matthew Heaney wrote:

> 
> "Marius Amado Alves" <amado.alves@netcabo.pt> wrote in message
> news:mailman.46.1098398641.10401.comp.lang.ada@ada-france.org...
>>> 1) Is it possible to use Get_Line with Unbounded and/or Bounded
>>> Strings?
>>
>> Not in the standard, but subprograms like those are usually around, e.g.
>> in the GNAT Library, or end up being written in house.
>>
>>> 2) If not, how should usei input be managed when lines length isn't
>>> known a priori?
>>
>> There's a way using the standard Get_Line, explained in AdaPower.
> 
> Mario is probably referring to an article I posted to CLA a few years'
> ago, and which is now archived at the adapower website.
> 
> The basic idea is this:  algorithms that consume input from a stream need
> a
> way a identify when all of the input has been consumed.  Typically this is
> done using a special value that you know is outside the range of normal
> values, e.g.

Well, you do not check for End_Of_File and that means your solution will
fail if the last line is not terminated with CR/LF. And if you want to
process files which have been edited by human beings than you have to care
for that case 

The following version does work. It hast been tested on hundreds of files
all edited by human beings:

package body
   --
   --  String IO Routienes. This are used because
   --  Ada.Strings.Unbounded.Text_IO and GNAT.IO_Aux both have a suttle
   --  little bug.
   --
   AdaCL.Strings.IO
is
   --
   --  Shorten some names.
   --
   package S_U     renames Ada.Strings.Unbounded;
   package S_Maps  renames Ada.Strings.Maps;
   package Latin_1 renames Ada.Characters.Latin_1;
   package IO      renames Ada.Text_IO;

   --  Buffer length. Works for any non-zero value, larger values take
   --  more stack space, smaller values require more recursion.
   BufferSize : constant := 2000;

   --
   --  Well, there are a lot of Get_Line routines around and GNAT
   --  certanly has its onwn, but all those I have seen have suttle bug:
   --  When the last line is not terminated with CR/LF and a multiple
   --  of buffersize long they will throw and end of file exception.
   --
   --  This version need recursion!
   --
   function Get_Line (
      --  File to be read.
      File : in IO.File_Type)
   return
      String
   is
      --  Trace : AdaCL.Trace.Object := AdaCL.Trace.Function_Trace
(AdaCL.Trace.Entity & ':' & AdaCL.Trace.Source);
      --  pragma Unreferenced (Trace);

      Buffer : String (1 .. BufferSize);
      Last   : Natural;
   begin
      IO.Get_Line (
         File => File,
         Item => Buffer,
         Last => Last);

      if Last < Buffer'Last then
         return Buffer (1 .. Last);
      elsif IO.End_Of_File (File) then
         return Buffer;
      else
         return Buffer & Get_Line (File);
      end if;
   end Get_Line;

   --
   --  Well, there are a lot of Get_Line routines around and GNAT
   --  certanly has its onwn, but all those I have seen have suttle bug:
   --  When the last line is not terminated with CR/LF and a multiple
   --  of buffersize long they will throw and end of file exception.
   --
   --  This version uses a loop.
   --
   function Get_Line (
      --  File to be read.
      File : in IO.File_Type)
   return
      S_U.Unbounded_String
   is
      --  Trace : AdaCL.Trace.Object := AdaCL.Trace.Function_Trace
(AdaCL.Trace.Entity & ':' & AdaCL.Trace.Source);
      --  pragma Unreferenced (Trace);

      Retval : S_U.Unbounded_String := S_U.Null_Unbounded_String;
      Item   : String (1 .. BufferSize);
      Last   : Natural;
   begin
      GetWholeLine :
      loop
         IO.Get_Line (
            File => File,
            Item => Item,
            Last => Last);

         S_U.Append (
            Source   => Retval,
            New_Item => Item (1 .. Last));

         exit GetWholeLine when Last < Item'Last
                      or   IO.End_Of_File (File);

      end loop GetWholeLine;

      return Retval;
   end Get_Line;

   --
   --  Get Next Word.
   --
   procedure Get_Word (
      --  File to be read.
      File : in Ada.Text_IO.File_Type;
      --  String into wich the word is to be read
      Item : out String;
      --  Actual amount of characters read.
      Last : out Natural;
      --  Word Delimiters
      Delimiters : in Ada.Strings.Maps.Character_Set := Word_Delimiters)
   is
      --  Trace : AdaCL.Trace.Object := AdaCL.Trace.Function_Trace
(AdaCL.Trace.Entity & ':' & AdaCL.Trace.Source);
      --  pragma Unreferenced (Trace);

      Next_Char : Character := Latin_1.NUL;
   begin
      Last := Item'First;

      Skip_Blanks :
      loop
         IO.Get (File => File,
               Item => Next_Char);

         --  AdaCL.Trace.Write (Integer'Image (Character'Pos (Next_Char)) &
"'" & String'(1 => Next_Char) & "'");

         exit Skip_Blanks when not S_Maps.Is_In (
                               Element => Next_Char,
                               Set     => Delimiters);
      end loop Skip_Blanks;

      Read_Char :
      loop

         if S_Maps.Is_In (Element => Next_Char,
                     Set     => Delimiters)
         then
            Last := Natural'Pred (Last);

            exit Read_Char;
         end if;

         --  AdaCL.Trace.Write (Integer'Image (Character'Pos (Next_Char)) &
"'" & String'(1 => Next_Char) & "'");

         Item (Last) := Next_Char;

         --  AdaCL.Trace.Write (Item (Item'First .. Last));

         Last := Natural'Succ (Last);

         exit Read_Char when Last = Item'Last;

         IO.Get (File => File,
               Item => Next_Char);

      end loop Read_Char;
   end Get_Word;

   --
   --  Get Next Word.
   --
   --  This version uses recursion! The actual version is garanteed to work
   --  up to words 2000 characters.
   --
   function Get_Word (
      --  File to be read.
      File : in IO.File_Type;
      --  Word Delimiters
      Delimiters : in S_Maps.Character_Set := Word_Delimiters)
   return
      String
   is
      --  Trace : AdaCL.Trace.Object := AdaCL.Trace.Function_Trace
(AdaCL.Trace.Entity & ':' & AdaCL.Trace.Source);
      --  pragma Unreferenced (Trace);

      Buffer : String (1 .. BufferSize);
      Last   : Natural;
   begin
      Get_Word (File       => File,
             Item       => Buffer,
             Last       => Last,
             Delimiters => Delimiters);

      if Last < Buffer'Last then
         return Buffer (1 .. Last);
      elsif IO.End_Of_File (File) then
         return Buffer;
      else
         return Buffer & Get_Word (File, Delimiters);
      end if;
   end Get_Word;

   --
   --  Get Next Word.
   --
   --  This version uses a loop. The actual version is garanteed to work
   --  up to words 2000 characters.
   --
   function Get_Word (
      --  File to be read.
      File : in IO.File_Type;
      --  Word Delimiters
      Delimiters : in Ada.Strings.Maps.Character_Set := Word_Delimiters)
   return
      S_U.Unbounded_String
   is
      --  Trace : AdaCL.Trace.Object := AdaCL.Trace.Function_Trace
(AdaCL.Trace.Entity & ':' & AdaCL.Trace.Source);
      --  pragma Unreferenced (Trace);

      Retval : S_U.Unbounded_String := S_U.Null_Unbounded_String;
      Item   : String (1 .. BufferSize);
      Last   : Natural;
   begin
      GetWholeLine : loop
         Get_Word (File       => File,
                Item       => Item,
                Last       => Last,
                Delimiters => Delimiters);

         S_U.Append (Source   => Retval,
                     New_Item => Item (1 .. Last));

         exit GetWholeLine when Last < Item'Last
                      or   IO.End_Of_File (File);

      end loop GetWholeLine;

      return Retval;
   end Get_Word;

end AdaCL.Strings.IO;

With Regards

Martin
-- 
mailto://krischik@users.sourceforge.net
http://www.ada.krischik.com




^ permalink raw reply	[relevance 4%]

* Re: variable lenght strings
    @ 2004-10-21 23:05  5% ` Stephen Leake
  1 sibling, 0 replies; 41+ results
From: Stephen Leake @ 2004-10-21 23:05 UTC (permalink / raw)
  To: comp.lang.ada

fmdf@tiscali.it (fabio de francesco) writes:

> 1) Is it possible to use Get_Line with Unbounded and/or Bounded
> Strings?

If you are using GNAT, you can use Ada.Strings.Unbounded.Text_IO.

> 2) If not, how should user input be managed when lines length isn't
> known a priori?

Ada.Text_IO.Get_Line takes a String argument; if it isn't
filled, you can call Ada.Strings.Unbounded on it.

The tricky part is what to do if your initial guess at a max length is
too short. You can write a loop; keep appending chunks of input until
Get_Line returns Last < Item'last.

> <snip stuff about Find_Token>
> 
> Ok, please let me know if the following is the correct usage:

"Correct usage" is whatever works for your application!
> 
> 
> with Ada.Text_IO, Ada.Strings, Ada.Strings.Fixed, 
>     Ada.Strings.Maps, Ada.Strings.Maps.Constants;
> use Ada.Text_IO, Ada.Strings, Ada.Strings.Fixed,
>     Ada.Strings.Maps, Ada.Strings.Maps.Constants;
> 
> procedure Tokenize is
>         
>     S : constant String := ".symbol HP = High_Pressure    "; -- Line A
>     F : Positive := S'First;
>     L : Natural := S'Last;
>     W : String( 1..30 );
>         
> begin
>   loop
>     Find_Token(S(F..L), Alphanumeric_Set or To_Set("_."), Inside, F,
> L);

It would be best to declare a variable to hold Alphanumeric_Set or
To_Set("_.").

>     if L /= 0 then

This could be 'exit when L = 0', but it's really a style issue.

>        Put_Line( Positive'Image( F ) & ( L - F ) * ' ' &
> Natural'Image( L ) );
>          Move( S( F..L ), W );

Named association is better here; I always forget which is the target
and which the source.

>          Put_Line( ' ' & W );
>          F := L + 1;
>          L := S'Last;
>     else 
>        exit;
>     end if;

>   end loop;      
> end Tokenize;
> 
> 
> Is it correct to check the "L" value as a condition to exit the
> loop?

Yes.

-- 
-- Stephe




^ permalink raw reply	[relevance 5%]

* Re: count_string program
  @ 2004-02-27 13:28  5% ` Stephen Leake
  0 siblings, 0 replies; 41+ results
From: Stephen Leake @ 2004-02-27 13:28 UTC (permalink / raw)
  To: comp.lang.ada

Cecilia Chew <cecilia@nowhere.com> writes:

> Hi all,
> I am doing a program that will count the input characters from user.
> There is a problem that I can't solve.
> Problem is : since I'm going to count the characters. So, I can't ask
> user how many characters they want to input. Compilation error come
> and mention that the string need to be constrainted.
> How am I going to constraint the string type since I don't know how
> many characters user going to input.

See Ada.Text_IO.Get_Line.

For that, you need to know in advance the maximum number of characters
the user might enter.

Or, if you are using GNAT, see Ada.Strings.Unbounded.Text_IO (not a
standard Ada package). Then you don't need a max in advance.

-- 
-- Stephe




^ permalink raw reply	[relevance 5%]

* Re: Computer Language Shootout
  2003-07-19 23:14  4%                       ` Samuel Tardieu
@ 2003-07-20  0:26  0%                         ` Robert I. Eachus
  0 siblings, 0 replies; 41+ results
From: Robert I. Eachus @ 2003-07-20  0:26 UTC (permalink / raw)


Samuel Tardieu wrote:
>>>>>>"Bob" == Robert A Duff <Robert> writes:
>>>>>
> 
> Bob> True, but I think the design goal of Text_IO ought to be
> Bob> correctness, and convenience for the programmer, not efficiency.
> Bob> I'm sick of programs that have arbitrary line-length limits.
> Bob> I'll happily pay a little efficiency cost to correct that.  And
> Bob> in the cases where efficiency matters, a different strategy can
> Bob> be used (namely, the Get_Line that takes a fixed-length buffer,
> Bob> or a get-next-token kind of approach, which doesn't care about
> Bob> line lengths).

> You can always use Ada.Strings.Unbounded.Text_IO.Get_Line and convert
> it to a string *after you check the length*. You will achieve the same
> effect and will not have to rely on (expensive or unreliable) stack
> checks.

A properly declared Get_Line function would make a reasonable addition 
to Ada.Text_IO.  (And probably similar functions in the nested 
generics.)  But the RM certainly wouldn't mandate any particular 
implementation.  I also think there should be a Get_Line procedure with 
an Unbounded_String parameter, and the same for Put_Line.

-- 

                                                 Robert I. Eachus

�In an ally, considerations of house, clan, planet, race are 
insignificant beside two prime questions, which are: 1. Can he shoot? 2. 
Will he aim at your enemy?� -- from the Laiden novels by Sharon Lee and 
Steve Miller.




^ permalink raw reply	[relevance 0%]

* Re: Computer Language Shootout
  @ 2003-07-19 23:14  4%                       ` Samuel Tardieu
  2003-07-20  0:26  0%                         ` Robert I. Eachus
  0 siblings, 1 reply; 41+ results
From: Samuel Tardieu @ 2003-07-19 23:14 UTC (permalink / raw)


>>>>> "Bob" == Robert A Duff <Robert> writes:

Bob> True, but I think the design goal of Text_IO ought to be
Bob> correctness, and convenience for the programmer, not efficiency.
Bob> I'm sick of programs that have arbitrary line-length limits.
Bob> I'll happily pay a little efficiency cost to correct that.  And
Bob> in the cases where efficiency matters, a different strategy can
Bob> be used (namely, the Get_Line that takes a fixed-length buffer,
Bob> or a get-next-token kind of approach, which doesn't care about
Bob> line lengths).

Bob,

while I understand why and where such a function would be practical, I
am opposed to it being part of the standard.

The reason is that it would make it much too easy to crash any Ada
program by feeding it with a long string that would exhaust the stack
area (be it the primary stack or, as in GNAT, a secondary stack). In
programs with tasking, the stack for each task is usually very
limited.

You can always use Ada.Strings.Unbounded.Text_IO.Get_Line and convert
it to a string *after you check the length*. You will achieve the same
effect and will not have to rely on (expensive or unreliable) stack
checks.

  Sam
-- 
Samuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/sam



^ permalink raw reply	[relevance 4%]

* Re: Visibility
       [not found]     <009C830A.36D4A463.0015D3EC@netscape.net>
@ 2003-06-07 12:18  0% ` David C. Hoos, Sr.
  0 siblings, 0 replies; 41+ results
From: David C. Hoos, Sr. @ 2003-06-07 12:18 UTC (permalink / raw)
  To: And838N, comp.lang.ada


----- Original Message ----- 
From: <And838N@netscape.net>
To: <comp.lang.ada@ada.eu.org>
Sent: June 07, 2003 3:21 AM
Subject: Visibility


> >Why did you "with" and "use" ada.text_io, when your program doesn't 
> >need them?  Elimination of this error solves the problem of visibility 
> >of "count". 
> Well, if I don't "with" ada.text_io I get the following message from
> gnatmake.
> iotest.adb:4:09: "put_line" is undefined
> iotest.adb:4:09: possible missing with of Text_IO
> iotest.adb:4:10: "put" is undefined
> iotest.adb:4:10: possible missing with of Text_IO
> hence, the reason I "withed" text_io.
> 
If you look at your original post (on June 4), there was no "put_line"
statement -- hence, the reason for my question 
> >I could find no such statement on my copy of Cohen's book. 
> Page 1039, Section A.2
> 
> >There is no such unit as "unbounded_text_io" in the Ada standard
> >libraries. 
> Hmmm...I have a "with" for Ada.strings.unbounded.text_io and the file 
> in <libdirectory>/adainclude/a-suteio.ads (using gcc-lib) says
> otherwise.  The package that has the Count function I am talking about
> is ada.strings.unbounded.
> 
> According to Cohen and obviously GNAT, the Count variable in text_io
> and the function with the same name from unbounded are visible in the
> same place, and for some reason it, GNAT, does not "determine" or maybe
> cannot determine which one to use by "signature".  To me, if anything,
> GNAT should have said something to the effect that I was trying to
> perform some sort of narrowing conversion rather than telling me that
> it did not know which Count to use because of a visibility issue.

First, Ada.Text_IO.Count is a _type_, not a variable as you state above.
Secondly, GNAT did _not_ tell you it didn't know which one to use.  It
told you (clearly and correctly) that multiple "use" clauses cause hiding,
which is correct according to the visibility rules. 
> 
> with
> ada.strings.unbounded,
> ada.text_io,
> ada.strings.maps;
> 
> use
> ada.strings.unbounded,
> ada.text_io,
> ada.strings.maps;
> 
> procedure visibilitytest is
>         astring: string := "hello world";
>         somenumber: integer;
> begin
>         put_line(astring);
>         somenumber := count(to_unbounded_string(astring), to_set(' '));
>         put_line(Integer'image(somenumber));
> end visibilitytest;
> 
> This code does not compile first because of a visibility issue.  The
> compiler output, gnatmake visibilitytest.adb -gnatf, yields:
> adagcc -c -gnatf visibilitytest.adb
> visibilitytest.adb:18:23: "count" is not visible
> visibilitytest.adb:18:23: multiple use clauses cause hiding
> visibilitytest.adb:18:23: hidden declaration at a-textio.ads:66
> visibilitytest.adb:18:23: hidden declaration at a-strunb.ads:217
> visibilitytest.adb:18:23: hidden declaration at a-strunb.ads:211
> visibilitytest.adb:18:23: hidden declaration at a-strunb.ads:205
> gnatmake: "visibilitytest.adb" compilation error
> 
> The fix is to specify which one to use on line 18.
> somenumber := ada.strings.unbounded.count(to_unbounded_string(as
> tring), to_set(' '));.  To me, GNAT should be able to resolve which
> count to use because the count in ada.strings.unbounded is a function
> and count in ada.text_io is a type.  Not to mention the function
> returns (or is of type) Natural, not count.
> 
> The answer to my question was in Cohen's book, chapter 10.  The 
> rules for the "with" clause and packages are to make a large 
> number of files easier to manage and to make it clear to the reader
> what is going on with any particular file.  The "with" clause just
> makes "stuff" visible; it is up to the programmer/engineer to specify
> or clarify, by using an expanded name, what facilities they are "use"
> ing from a particular package.  Thus, GNAT's compiler message tells
> me not that GNAT can't determine which count to use but that I need
> to specify, for future readers, which count I needed.  In doing so
> ,if I am searching for count, I narrow the search to the exact 
> package I need to look in for the count I "used". 
> 
> I'll be looking into Elaboration next.  It sounds to me like the 
> elaboration of a package is like the instantiation of a C++ class.
> If that's true, then I should be able to have multiple elaborations
> of a package that all have different values for their data members.
> And if that is true, then I've been using the package the wrong way.

Elaboration is nothing at all like the instantiation of a C++ class.
Elaboration is a _process_ that takes place at program startup wherein
declarations are executed -- e.g. to initialize a constant or variable.

Suppose you had the following declarations in the specification of a
package named my_pkg:

angle : Long_Float := 13.0;
base : Long_Float := 1234.5;
package Long_Float_Elementary_Functions is new
   Ada.Numerics.Generic_Elementary_Functions (Long_Float);
use Long_Float_Elementary_Functions;
altitude : Long_Float := base * Sin (angle * Ada.Numerics.Pi / 180.0);

Using the GNAT compiler, the object file resulting from the compilation
of your package would contain a procedure named my_pkg___elabs.

That procedure contains the elaboration code for your package
specification.

When compiling your main program, the compiler will insert code to
call that elaboration procedure as well as the elaboration procedures
of all of the compilation units making up your program.

_That's_ what elaboration is.

> 
> Thanks for the help all.
> 
> Andrew
> 
> __________________________________________________________________
> McAfee VirusScan Online from the Netscape Network.
> Comprehensive protection for your entire computer. Get your free trial today!
> http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397
> 
> Get AOL Instant Messenger 5.1 free of charge.  Download Now!
> http://aim.aol.com/aimnew/Aim/register.adp?promo=380455
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada.eu.org
> http://ada.eu.org/mailman/listinfo/comp.lang.ada
> 
> 




^ permalink raw reply	[relevance 0%]

* Visibility
@ 2003-06-07  8:21  6% And838N
  0 siblings, 0 replies; 41+ results
From: And838N @ 2003-06-07  8:21 UTC (permalink / raw)
  To: comp.lang.ada

>Why did you "with" and "use" ada.text_io, when your program doesn't 
>need them?  Elimination of this error solves the problem of visibility 
>of "count". 
Well, if I don't "with" ada.text_io I get the following message from
gnatmake.
iotest.adb:4:09: "put_line" is undefined
iotest.adb:4:09: possible missing with of Text_IO
iotest.adb:4:10: "put" is undefined
iotest.adb:4:10: possible missing with of Text_IO
hence, the reason I "withed" text_io.
 
>I could find no such statement on my copy of Cohen's book. 
Page 1039, Section A.2

>There is no such unit as "unbounded_text_io" in the Ada standard
>libraries. 
Hmmm...I have a "with" for Ada.strings.unbounded.text_io and the file 
in <libdirectory>/adainclude/a-suteio.ads (using gcc-lib) says
otherwise.  The package that has the Count function I am talking about
is ada.strings.unbounded.

According to Cohen and obviously GNAT, the Count variable in text_io
and the function with the same name from unbounded are visible in the
same place, and for some reason it, GNAT, does not "determine" or maybe
cannot determine which one to use by "signature".  To me, if anything,
GNAT should have said something to the effect that I was trying to
perform some sort of narrowing conversion rather than telling me that
it did not know which Count to use because of a visibility issue.

with
ada.strings.unbounded,
ada.text_io,
ada.strings.maps;

use
ada.strings.unbounded,
ada.text_io,
ada.strings.maps;

procedure visibilitytest is
        astring: string := "hello world";
        somenumber: integer;
begin
        put_line(astring);
        somenumber := count(to_unbounded_string(astring), to_set(' '));
        put_line(Integer'image(somenumber));
end visibilitytest;

This code does not compile first because of a visibility issue.  The
compiler output, gnatmake visibilitytest.adb -gnatf, yields:
adagcc -c -gnatf visibilitytest.adb
visibilitytest.adb:18:23: "count" is not visible
visibilitytest.adb:18:23: multiple use clauses cause hiding
visibilitytest.adb:18:23: hidden declaration at a-textio.ads:66
visibilitytest.adb:18:23: hidden declaration at a-strunb.ads:217
visibilitytest.adb:18:23: hidden declaration at a-strunb.ads:211
visibilitytest.adb:18:23: hidden declaration at a-strunb.ads:205
gnatmake: "visibilitytest.adb" compilation error

The fix is to specify which one to use on line 18.
somenumber := ada.strings.unbounded.count(to_unbounded_string(as
tring), to_set(' '));.  To me, GNAT should be able to resolve which
count to use because the count in ada.strings.unbounded is a function
and count in ada.text_io is a type.  Not to mention the function
returns (or is of type) Natural, not count.

The answer to my question was in Cohen's book, chapter 10.  The 
rules for the "with" clause and packages are to make a large 
number of files easier to manage and to make it clear to the reader
what is going on with any particular file.  The "with" clause just
makes "stuff" visible; it is up to the programmer/engineer to specify
or clarify, by using an expanded name, what facilities they are "use"
ing from a particular package.  Thus, GNAT's compiler message tells
me not that GNAT can't determine which count to use but that I need
to specify, for future readers, which count I needed.  In doing so
,if I am searching for count, I narrow the search to the exact 
package I need to look in for the count I "used". 

I'll be looking into Elaboration next.  It sounds to me like the 
elaboration of a package is like the instantiation of a C++ class.
If that's true, then I should be able to have multiple elaborations
of a package that all have different values for their data members.
And if that is true, then I've been using the package the wrong way.

Thanks for the help all.

Andrew

__________________________________________________________________
McAfee VirusScan Online from the Netscape Network.
Comprehensive protection for your entire computer. Get your free trial today!
http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397

Get AOL Instant Messenger 5.1 free of charge.  Download Now!
http://aim.aol.com/aimnew/Aim/register.adp?promo=380455



^ permalink raw reply	[relevance 6%]

* Re: I/O - exception handling
  2003-05-27  2:36  6% ` Anisimkov
@ 2003-05-27  7:21  0%   ` Sergey Koshcheyev
  0 siblings, 0 replies; 41+ results
From: Sergey Koshcheyev @ 2003-05-27  7:21 UTC (permalink / raw)


Anisimkov wrote:
> "Sergey Koshcheyev" <serko84@hotmail.com> wrote in message
> Your should not catch exception on the Close, becouse Ada95 RM A.8.2 File
> Management
> says "The exception Status_Error is propagated if the given file is not
> open.". So if file is Open, you do not need to wait exception. I thing GNAT
> spetsific Ada.Strings.Unbounded.Text_IO.Close have the same behavior. If you
> are want to catch exception anyway (for example you are using any other IO
> implementation.) you can make local procedure inside of Read_Something.

(The File_Type, Open and Close that were used in my example are from 
Ada.Text_IO, only Get_Line comes from A.S.U.Text_IO, and that's a 
function, not a procedure as I used it originally. But the example was 
only meant to illustrate, I'm sorry for the confusion.)

I've seen the paragraph, but I don't know if it can be read as "the only 
exception that may be propagated from Close is Status_Error, and that 
only if the file was not open" - the clause doesn't give me any such 
guarantees.

For example, I think Close is legally allowed to raise Device_Error, or 
even Use_Error.

>  begin
>     Open (File, Name => "test.txt", Mode => In_File);
>     Get_Line (File, S1);
>     Get_Line (File, S2);
>     Close_File;
> 
>  exception
>     when others =>
>          Close_File;
> end Read_Something;

This closes the file twice, as does the example below - something I 
don't like.

> But, in my point of view, it is bad practice to suppress exception
> completely. I prefer to know about errors in program execution. If we do not
> suppress exception, code become simplier. We need to catch exceptions only in
> Get_Line routines. Exceptions in Open routine do not need to be catched
> becouse we do not need to close not opened file. For the Ada semantic File we
> can write just.

I hereby promise I won't ignore the I/O exceptions in real code (or at 
least I'll try not to :-)), that example was just an example.

> exception
>     when Device_Error | Data_Error =>
>           --  Device_Error and Data_Error could be raised only on IO
> operations
>           --  So the file is already opened and we do not need to check is
> file open
>           --  before close.

But Open and Close may raise Device_Error too?

>           Close_File (File);

Again, you have to remember to close the file in two places.

>           raise;
> end Read_Something;

Sergey.




^ permalink raw reply	[relevance 0%]

* Re: I/O - exception handling
  2003-05-26 13:05  5% I/O - exception handling Sergey Koshcheyev
  2003-05-26 14:52  0% ` Jean-Pierre Rosen
  2003-05-26 16:31  0% ` Steve
@ 2003-05-27  2:36  6% ` Anisimkov
  2003-05-27  7:21  0%   ` Sergey Koshcheyev
  2 siblings, 1 reply; 41+ results
From: Anisimkov @ 2003-05-27  2:36 UTC (permalink / raw)



"Sergey Koshcheyev" <serko84@hotmail.com> wrote in message
news:bat3ee$2ec$1@ns.felk.cvut.cz...

> procedure Read_Something (...) is
>    use Ada.Text_IO;
>    use Ada.Strings.Unbounded;
>    use Ada.Strings.Unbounded.Text_IO;
>    --  GNAT-specific package, I believe
>
>    File : File_Type;
>    S1, S2 : Unbounded_String;
>
> begin
>    Open (File, Name => "test.txt", Mode => In_File);
>    Get_Line (File, S1);
>    Get_Line (File, S2);
>    Close (File);
>
> exception
>    when others =>
>       if Is_Open (File) then
>          begin
>             Close (File);
>          exception
>             --  Close can raise exceptions too!
>             when others => null;
>          end;
>       end if;
> end Read_Something;
>
> However, this looks ugly to me, since I have to close the file in two
> places, and also guard for exceptions while handling exceptions. Is there a
> better solution or is this sort of thing OK in the Ada way?

Your should not catch exception on the Close, becouse Ada95 RM A.8.2 File
Management
says "The exception Status_Error is propagated if the given file is not
open.". So if file is Open, you do not need to wait exception. I thing GNAT
spetsific Ada.Strings.Unbounded.Text_IO.Close have the same behavior. If you
are want to catch exception anyway (for example you are using any other IO
implementation.) you can make local procedure inside of Read_Something.

 procedure Read_Something (...) is
    use Ada.Text_IO;
    use Ada.Strings.Unbounded;
    use Ada.Strings.Unbounded.Text_IO;
    --  GNAT-specific package, I believe

    File : File_Type;
    S1, S2 : Unbounded_String;

   procedure Close_File is
   begin
       if Is_Open (File) then
          begin
             Close (File);
          exception
             --  Close can raise exceptions too!
             when others => null;
          end;
       end if;
   end Close_File;

 begin
    Open (File, Name => "test.txt", Mode => In_File);
    Get_Line (File, S1);
    Get_Line (File, S2);
    Close_File;

 exception
    when others =>
         Close_File;
end Read_Something;

But, in my point of view, it is bad practice to suppress exception
completely. I prefer to know about errors in program execution. If we do not
suppress exception, code become simplier. We need to catch exceptions only in
Get_Line routines. Exceptions in Open routine do not need to be catched
becouse we do not need to close not opened file. For the Ada semantic File we
can write just.

 procedure Read_Something (...) is
    use Ada.Text_IO;
    use Ada.Strings.Unbounded;
    use Ada.Strings.Unbounded.Text_IO;
    --  GNAT-specific package, I believe

    File : File_Type;
    S1, S2 : Unbounded_String;


begin
    Open (File, Name => "test.txt", Mode => In_File);
    Get_Line (File, S1);
    Get_Line (File, S2);
    Close (File);

exception
    when Device_Error | Data_Error =>
          --  Device_Error and Data_Error could be raised only on IO
operations
          --  So the file is already opened and we do not need to check is
file open
          --  before close.

          Close_File (File);
          raise;
end Read_Something;






^ permalink raw reply	[relevance 6%]

* Re: I/O - exception handling
  2003-05-26 13:05  5% I/O - exception handling Sergey Koshcheyev
  2003-05-26 14:52  0% ` Jean-Pierre Rosen
@ 2003-05-26 16:31  0% ` Steve
  2003-05-27  2:36  6% ` Anisimkov
  2 siblings, 0 replies; 41+ results
From: Steve @ 2003-05-26 16:31 UTC (permalink / raw)


Here's an approach that only uses close once, but it isn't pretty either.

 begin
    begin
       begin
          Open (File, Name => "test.txt", Mode => In_File);
       exception
            when others =>
                null; -- report exception opening file ???
                return;
       end;
       Get_Line (File, S1);
       Get_Line (File, S2);
    exception
       when others =>
           null; -- report exception???
    end;
    Close (File);
 exception
    when others =>
      null; -- report exception ???
 end Read_Something;

Steve
(The Duck)

"Sergey Koshcheyev" <serko84@hotmail.com> wrote in message
news:bat3ee$2ec$1@ns.felk.cvut.cz...
> Hi,
>
> I have this problem: I have a simple piece of code opening a file, reading
a
> few lines, then closing it. Now, I want this piece of code to be "safe",
> i.e. not to leak any resources (the open file) in case of errors and not
to
> propagate any exceptions. What is the best style to write this code?
>
> Currently, I have something like (not compiled):
>
> procedure Read_Something (...) is
>    use Ada.Text_IO;
>    use Ada.Strings.Unbounded;
>    use Ada.Strings.Unbounded.Text_IO;
>    --  GNAT-specific package, I believe
>
>    File : File_Type;
>    S1, S2 : Unbounded_String;
>
> begin
>    Open (File, Name => "test.txt", Mode => In_File);
>    Get_Line (File, S1);
>    Get_Line (File, S2);
>    Close (File);
>
> exception
>    when others =>
>       if Is_Open (File) then
>          begin
>             Close (File);
>          exception
>             --  Close can raise exceptions too!
>             when others => null;
>          end;
>       end if;
> end Read_Something;
>
> However, this looks ugly to me, since I have to close the file in two
> places, and also guard for exceptions while handling exceptions. Is there
a
> better solution or is this sort of thing OK in the Ada way?
>
> Sergey.
>
>





^ permalink raw reply	[relevance 0%]

* Re: I/O - exception handling
  2003-05-26 13:05  5% I/O - exception handling Sergey Koshcheyev
@ 2003-05-26 14:52  0% ` Jean-Pierre Rosen
  2003-05-26 16:31  0% ` Steve
  2003-05-27  2:36  6% ` Anisimkov
  2 siblings, 0 replies; 41+ results
From: Jean-Pierre Rosen @ 2003-05-26 14:52 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1420 bytes --]


"Sergey Koshcheyev" <serko84@hotmail.com> a �crit dans le message de news:bat3ee$2ec$1@ns.felk.cvut.cz...
[..]
> procedure Read_Something (...) is
>    use Ada.Text_IO;
>    use Ada.Strings.Unbounded;
>    use Ada.Strings.Unbounded.Text_IO;
>    --  GNAT-specific package, I believe
>
>    File : File_Type;
>    S1, S2 : Unbounded_String;
>
> begin
>    Open (File, Name => "test.txt", Mode => In_File);
>    Get_Line (File, S1);
>    Get_Line (File, S2);
>    Close (File);
>
> exception
>    when others =>
>       if Is_Open (File) then
>          begin
>             Close (File);
>          exception
>             --  Close can raise exceptions too!
>             when others => null;
>          end;
>       end if;
> end Read_Something;

Doing so will make the exception disappear. You exception handler should rather read:
 exception
    when others =>
       if Is_Open (File) then
          begin
             Close (File);
          exception
             --  Close can raise exceptions too!
             when others => null;
          end;
       end if;
       raise;   -- Reraise the original exception, even if you had another exception at close
 end Read_Something;

> However, this looks ugly to me, since I have to close the file in two
> places, and also guard for exceptions while handling exceptions. Is there a
> better solution or is this sort of thing OK in the Ada way?
>
> Sergey.
>
>





^ permalink raw reply	[relevance 0%]

* I/O - exception handling
@ 2003-05-26 13:05  5% Sergey Koshcheyev
  2003-05-26 14:52  0% ` Jean-Pierre Rosen
                   ` (2 more replies)
  0 siblings, 3 replies; 41+ results
From: Sergey Koshcheyev @ 2003-05-26 13:05 UTC (permalink / raw)


Hi,

I have this problem: I have a simple piece of code opening a file, reading a
few lines, then closing it. Now, I want this piece of code to be "safe",
i.e. not to leak any resources (the open file) in case of errors and not to
propagate any exceptions. What is the best style to write this code?

Currently, I have something like (not compiled):

procedure Read_Something (...) is
   use Ada.Text_IO;
   use Ada.Strings.Unbounded;
   use Ada.Strings.Unbounded.Text_IO;
   --  GNAT-specific package, I believe

   File : File_Type;
   S1, S2 : Unbounded_String;

begin
   Open (File, Name => "test.txt", Mode => In_File);
   Get_Line (File, S1);
   Get_Line (File, S2);
   Close (File);

exception
   when others =>
      if Is_Open (File) then
         begin
            Close (File);
         exception
            --  Close can raise exceptions too!
            when others => null;
         end;
      end if;
end Read_Something;

However, this looks ugly to me, since I have to close the file in two
places, and also guard for exceptions while handling exceptions. Is there a
better solution or is this sort of thing OK in the Ada way?

Sergey.





^ permalink raw reply	[relevance 5%]

* strange execution error
@ 2003-02-22 22:31  5% alfonso acosta
  0 siblings, 0 replies; 41+ results
From: alfonso acosta @ 2003-02-22 22:31 UTC (permalink / raw)


Hi:

I recently started a project in savannah called adabot 
(https://savannah.nongnu.org/projects/adabot/). Its a realtimebattle 
(http://realtimebattle.sourceforge.net/) bot developed completely in Ada.

The problem I have, is the following:

When trying to test a package which isnt finished (messages.ads in
http://savannah.nongnu.org/cgi-bin/viewcvs/adabot/adabot/src/)
with this procedure:

-----
with Ada.Strings.Unbounded.Text_IO, Ada.Interrupts.Names ;
use  Ada.Strings.Unbounded.Text_IO, Ada.Interrupts.Names, Ada.Interrupts;

procedure Messages.Test is

    Msg : Msg_From_Robot;
    Str : Unbounded_String;
begin

    Msg := (RobotOption, (Signal, SIGUSR1));
    Msg2Str (Msg, Str);
    Put (Str);
end Messages.Test;
-----

After compiling with GNAT I execute it and it gets completely frozen, 
the most curious about it is that 4 processes are created. Gdb tells me 
the error comes from messages.adb line 152:


  Append(Source   => Str,
         New_Item => Interrupt_ID'Pos(Msg.Value.Which));

but I dont understand why its wrong

Can anybody have a look at the code?

Thanks in advance:

Alfonso Acosta

PS: If anyone is interested in the project Ill be pleased to give 
him/her a CVS write account (Its obvoius that Im not an experienced Ada 
programmer and need some help)




^ permalink raw reply	[relevance 5%]

* read filename and then open text file
@ 2002-11-16 20:07  6% Bjoern Schiessle
  0 siblings, 0 replies; 41+ results
From: Bjoern Schiessle @ 2002-11-16 20:07 UTC (permalink / raw)


Hello,
I am an Ada beginner and try do read a filename and then open the file,
but it doesn't work.

I have tried this:

with Ada.Text_IO;
with Ada.Strings.Unbounded;
with Ada.Strings.Unbounded.Text_IO;
use Ada.Text_IO;
use Ada.Strings.Unbounded;
use Ada.Strings.Unbounded.Text_IO;

procedure test is
   file : File_Type;
   filename : Unbounded_String;
begin
   Put_line("Geben Sie das zu erratende Wort ein (nur grossbuchstaben):");
   Put(">");
   Wort := Get_Line;
   Open(Datei, In_File, Dateiname);
   ...

but it doesn't work. I get the message:

expected type "Standard.String"
found private type "Ada.Strings.Unbounded.Unbounded_String"

I have no idea how i must read the filename. Can someone help me?

Thanks a lot
Bjoern



^ permalink raw reply	[relevance 6%]

* Re: Get_Line
  @ 2002-11-01 23:32  5%                   ` Matthew Heaney
  0 siblings, 0 replies; 41+ results
From: Matthew Heaney @ 2002-11-01 23:32 UTC (permalink / raw)



"Chad R. Meiners" <crmeiners@hotmail.com> wrote in message
news:apuqd0$103i$1@msunews.cl.msu.edu...
>
> Would you be happy with the following instead?
>
> type Line is private;
>
> procedure Get_Line (File : File_Type; Item : out Line);
>

You already have a resizable string type, so you'd be better off using that.
The easiest solution would be to create a child of Ada.Strings.Unbounded:

with Ada.Text_IO;
package Ada.Strings.Unbounded.Text_IO is
   procedure Get_Line (File : File_Type; Item : out Unbounded_String);
end;

> function  To_String (Item : Line) return String;

Note that this isn't terribly efficient, for the same reasons
Ada.Strings.Unbounded is inefficient.  At least GNAT has
Ada.Strings.Unbounded.Aux, which allows you to get at the internal string
directly.

In C++, I can return a reference.  Something like:

class C
{
public:
   const std::string& f() const;
//...
};

The closest thing in Ada is to use an access type:

type Line_Type is private;

type String_Access is access all String;

function To_String_Access (Line : Line_Type) return String_Access;

and then you could:

declare
   S : String renames To_String_Access (Line).all;  --no copying
begin

You could tighten the safety by being able to decorate the access type, e.g.

type String_Access (<>) is limited access all String;

which would prevent users from holding on to a copy of the access value
returned by the selector function (forcing them to do a rename, as above).

All the Charles containers use this technique, to allow in-place
manipluation of container elements.  So you typically have a pair of
functions:

   function Element (Container : Container_Type)
     return Element_Type;

   generic
     type Element_Access is access all Element_Type;
   function Generic_Element (Container : Container_Type)
     return Element_Access;

This is analogous to the iterator dereference operators:

   value_type& operator*() const;

which allows you to do this:

   int& histogram = *iter;
   ++histogram;

This kind of in-place manipulation is awkward without references.  In my
container example above, you'd have:

declare
   Histogram : Integer renames To_Access (Iterator).all;
begin
   Histogram := Histogram + 1;
end;

See the Charles page for more info:

http://home.earthlink.net/~matthewjheaney/charles/charles-vectors-unbounded.
html

http://home.earthlink.net/~matthewjheaney/charles/index.html

Matt








^ permalink raw reply	[relevance 5%]

* Re: Ada2005
  2001-12-12 18:40  0%           ` Ada2005 Ted Dennison
@ 2001-12-12 19:12  0%             ` Mark Lundquist
  0 siblings, 0 replies; 41+ results
From: Mark Lundquist @ 2001-12-12 19:12 UTC (permalink / raw)



"Ted Dennison" <dennison@telepath.com> wrote in message
news:rwNR7.59129$xS6.96048@www.newsranger.com...
> In article <o8NR7.13079$7y.147028@rwcrnsc54>, Mark Lundquist says...
> >
> >No... you can do this
> >
> >in Foo.h:
> >
> >    class Foo {
> >        static int i;
> >        .
> >        .
> >
> >in Foo.C (typically):
> >
> >    int Foo::i = something;
>
> Perhaps that might be marginally better for *some* purposes than doing the
same
> thing with a deferred constant in Ada. If you like the fact that the value
is
> hidden away in the body, you can get the exact same effect with an inlined
> function if you really want to.
>

No, you misunderstand me... I'm not saying anything is better in C++ or that
anything would be better if it were different in Ada.  It sounded like you
didn't know about static class members, and were saying that static data
members were a workaround (to get the effect of a classwide constant).  You
said something about the stoopidity of having each instance carry around its
own copy of a constant, and said (I thought) that the only reason to do that
would be because C++ doesn't have anywhere else (like a package) to put
it... but they do.

> >I think what the OP means is something like a const data member in C++.
If
> >so, he should learn about discriminants.
>
> Ahhh. I thought the issue was class-wide constants. Either way though, you
can
> do this just fine in Ada today.
>

True of course.  My point was just that you can also do that in C++ (you
seemed to be denying this).

> >> Perhaps there should be a revision in there to include a version of
> >> Get_Line implemented as a function.
> >
> >...such as GNAT's Ada.Strings.Unbounded.Text_IO.Get_Line.  I think it
would
> >be great if that were added to the standard in a language revision.
>
> Yes; basicly that, but returning "String" instead of
> "Ada.Strings.Unbounded.Unbounded_String". Just toss it into Ada.Text_IO
and be
> done with the whole issue.
>

There you go.  Although I think in practice it wouldn't find as much use as
the unbounded version.  You usually don't do just one Get_Line... :-).

I would guess that GNAT didn't provide this for fixed Strings just because
it's useful only in a special case, and using unbounded strings in that case
is not all that much less convenient than fixed.

Best,
-- mark






^ permalink raw reply	[relevance 0%]

* Re: Ada2005
  2001-12-12 18:14  4%         ` Ada2005 Mark Lundquist
@ 2001-12-12 18:40  0%           ` Ted Dennison
  2001-12-12 19:12  0%             ` Ada2005 Mark Lundquist
  0 siblings, 1 reply; 41+ results
From: Ted Dennison @ 2001-12-12 18:40 UTC (permalink / raw)


In article <o8NR7.13079$7y.147028@rwcrnsc54>, Mark Lundquist says...
>
>"Ted Dennison" <dennison@telepath.com> wrote in message
>news:nxKR7.58838$xS6.95364@www.newsranger.com...
>> Why would anyone want to? Isn't it rather stupid to allocate space in
>several
>> objects to a field that will always be the same? I understand why C++ does
>this:
>> they don't have packages to put their constants into. So if one wants to
>> associate a constant with a class, there is no choice but to do it this
>way and
>> waste the space.
>
>No... you can do this
>
>in Foo.h:
>
>    class Foo {
>        static int i;
>        .
>        .
>
>in Foo.C (typically):
>
>    int Foo::i = something;

Perhaps that might be marginally better for *some* purposes than doing the same
thing with a deferred constant in Ada. If you like the fact that the value is
hidden away in the body, you can get the exact same effect with an inlined
function if you really want to.

>I think what the OP means is something like a const data member in C++.  If
>so, he should learn about discriminants.

Ahhh. I thought the issue was class-wide constants. Either way though, you can
do this just fine in Ada today.

>> Perhaps there should be a revision in there to include a version of
>> Get_Line implemented as a function.
>
>...such as GNAT's Ada.Strings.Unbounded.Text_IO.Get_Line.  I think it would
>be great if that were added to the standard in a language revision.

Yes; basicly that, but returning "String" instead of
"Ada.Strings.Unbounded.Unbounded_String". Just toss it into Ada.Text_IO and be
done with the whole issue.


---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html

No trees were killed in the sending of this message. 
However a large number of electrons were terribly inconvenienced.



^ permalink raw reply	[relevance 0%]

* Re: Ada2005
  @ 2001-12-12 18:14  4%         ` Mark Lundquist
  2001-12-12 18:40  0%           ` Ada2005 Ted Dennison
  0 siblings, 1 reply; 41+ results
From: Mark Lundquist @ 2001-12-12 18:14 UTC (permalink / raw)



"Ted Dennison" <dennison@telepath.com> wrote in message
news:nxKR7.58838$xS6.95364@www.newsranger.com...
> In article <9v7q8r$1f5$1@infosun2.rus.uni-stuttgart.de>, Peter Hermann
says...
> >
> >Carsten Freining <freining@informatik.uni-jena.de> wrote:
> >> Best example is the object oriented part, because it is not possible to
have
> >> constants as components.
> >
> >Compiler maintainers may insert the already existing keywork "constant"
> >in coffee break time.

It'd be better if others would study RM 3.7 during their coffee break time
:-)

>
> Why would anyone want to? Isn't it rather stupid to allocate space in
several
> objects to a field that will always be the same? I understand why C++ does
this:
> they don't have packages to put their constants into. So if one wants to
> associate a constant with a class, there is no choice but to do it this
way and
> waste the space.

No... you can do this

in Foo.h:

    class Foo {
        static int i;
        .
        .

in Foo.C (typically):

    int Foo::i = something;

It's kind of wack, but we do have this in C++.

I think what the OP means is something like a const data member in C++.  If
so, he should learn about discriminants.

> >> And there is still the fixed length String. I don't think it is
neccessary.
> >
> >The fixed length string is a core requirement for
> >bread_and_butter_softworkers.
>
> I don't think the poster has much experience with Ada strings. Anyone who
truly
> understood Ada strings would never say something like this. In fact, its
almost
> the *opposite* of what is true. Its fairly rare that I ever need to use
> Ada.Strings.* (well...some of the stuff in Ada.Strings.Fixed comes in
handy
> fairly often :-) ).
>
> >> compatibility they both can still be available, but I think it is an
ancient
> >> thing to still have a fixed length String were only String with exactly
the
> >> same length can be assigned.
>
> This is part of the core misunderstanding here. Its unusual that one ever
needs
> to "modify" a string, once its initial value is set. Most of what others
may
> consider "modifications" are actually dynamicly arriving at the initial
value,
> or building new strings using old ones as a base. Both of these situations
can
> usually be handled just fine with Ada's "old-fashioned" fixed strings.

Yes to all of the above.

>
> I think part of the stumbling block here for beginners is that one of the
> exceptions to this is one of the first things they will try to do:
Ada.Text_IO.
> Perhaps there should be a revision in there to include a version of
Get_Line
> implemented as a function.

...such as GNAT's Ada.Strings.Unbounded.Text_IO.Get_Line.  I think it would
be great if that were added to the standard in a language revision.

> That would allow beginners to get off on the right
> foot with string manipulation. This seems to be a legitimate problem.
>

Agreed!

-- mark






^ permalink raw reply	[relevance 4%]

* Re: string input
  2001-11-27  6:25  4%   ` Mark Lundquist
@ 2001-11-27  9:33  0%     ` Lutz Donnerhacke
  0 siblings, 0 replies; 41+ results
From: Lutz Donnerhacke @ 2001-11-27  9:33 UTC (permalink / raw)


* Mark Lundquist wrote:
>"Robert Dewar" <dewar@gnat.com> wrote in message
>> Note that if you are using GNAT, the function
>> Ada.Strings.Unbounded.Get_Line is very convenient
>> for reading strings of varying length.
>
>I believe it's Ada.Strings.Unbounded.Text_Io.Get_Line

GNAT tends to use recursion, which is known to genereate problems.
 Problematic version:
   http://www.iks-jena.de/mitarb/lutz/ada/reverse_line_tokens__adb.htm
 Scalable version:
   http://www.iks-jena.de/mitarb/lutz/ada/shuffle_text_tokens__adb.htm




^ permalink raw reply	[relevance 0%]

* Re: string input
  @ 2001-11-27  6:25  4%   ` Mark Lundquist
  2001-11-27  9:33  0%     ` Lutz Donnerhacke
  0 siblings, 1 reply; 41+ results
From: Mark Lundquist @ 2001-11-27  6:25 UTC (permalink / raw)



"Robert Dewar" <dewar@gnat.com> wrote in message
news:5ee5b646.0111262005.74c646cc@posting.google.com...

> Note that if you are using GNAT, the function
> Ada.Strings.Unbounded.Get_Line is very convenient
> for reading strings of varying length.

I believe it's Ada.Strings.Unbounded.Text_Io.Get_Line

-- mark






^ permalink raw reply	[relevance 4%]

* How do I free unbounded strings?
@ 2001-03-05 17:03  6% Erik Sigra
  0 siblings, 0 replies; 41+ results
From: Erik Sigra @ 2001-03-05 17:03 UTC (permalink / raw)
  To: comp.lang.ada

Hi,

This is my first post to this mailinglist/newsgroup. I use Gnat 3.13p 
downloaded from <http://www.gnuada.org/rpms313p.html>. In the rationale at 
<http://www.adapower.com/rationale/rat95-p3-a.html> i read:

  For unbounded strings the ":=" operation does the necessary storage
  management through Adjust and Finalize operations to allocate needed space
  for the new value of the target and to reclaim the space previously
  occupied by the object.

Then I tried this simple program:

  with Ada.Strings.Unbounded;         use Ada.Strings.Unbounded;
  with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO;
  with Ada.Text_IO;                   use Ada.Text_IO;

  procedure Prov is
     Unbounded_String_1 : Unbounded_String;
  begin
     Put ("Enter an unbounded string: ");
     Unbounded_String_1 := Get_Line; --  First Pause
     Put ("Check how much memory the program uses and press return: ");
     while not End_Of_Line loop null; -- Second Pause
     end loop;
     Skip_Line;
     Unbounded_String_1 := Null_Unbounded_String;
     Put ("The unbounded string has been freed. Check how much memory the"
          & " program uses and press return: ");
     while not End_Of_Line loop null; -- Third Pause
     end loop;
     Skip_Line;
  end Prov;

At First Pause the program always uses (880, 880, 776) memory. At Second 
Pause the program uses at least (888, 888, 780) memory. If I enter a long 
string this can be for example (900, 900, 784). At Third Pause the program 
uses exactly as much memory as at Second Pause.

The memory values are labelled ("Virtual image size of process in Kbytes", 
"Resitent set size; Kbytes of program in memory", "Shared memory in Kbytes").

So it appears to me as if freeing doesn't work as the rationale says. Could 
someone please help me with this?




^ permalink raw reply	[relevance 6%]

* Re: Newbie Questions about Get, Get_Line
  @ 2000-12-31 17:03  6%     ` Robert Dewar
  0 siblings, 0 replies; 41+ results
From: Robert Dewar @ 2000-12-31 17:03 UTC (permalink / raw)


In article <98pt4t477fqavihkgfbjioo7peo9vb7f20@4ax.com>,
  gressett@iglobal.net wrote:
> The real problem here is that the designers of the
Ada.Text_IO package
> quit too soon. There should have been an Ada.Interactive_IO
which
> would deal with more of the problems of screen and Keyboard
IO in a
> standard way.


Perhaps, but the problem in this thread is trivially solvable
with the current Text_IO facilities, so I don't think this is
a good argument for the point.

Now if you are using Unbounded strings, then there really
are missing routines, which is why GNAT supplies:

with Ada.Text_IO;

package Ada.Strings.Unbounded.Text_IO is

   function Get_Line return Unbounded_String;
   function Get_Line (File : Ada.Text_IO.File_Type)
     return Unbounded_String;
   --  Reads up to the end of the current line, returning the
   --  result as an unbounded string of appropriate length. If
   --  no File parameter is present, input is from
   --  Current_Input.

   procedure Put (U : Unbounded_String);
   procedure Put
    (File : Ada.Text_IO.File_Type;
      U   : Unbounded_String);
   procedure Put_Line U : Unbounded_String);
   procedure Put_Line
     (File : Ada.Text_IO.File_Type;
      U    : Unbounded_String);
   --  These are equivalent to the standard Text_IO routines
   --  passed the value To_String (U), but operate more
   --  efficiently, because the extra copy of the argument is
   --  avoided.

end Ada.Strings.Unbounded.Text_IO;


Sent via Deja.com
http://www.deja.com/



^ permalink raw reply	[relevance 6%]

* ANNOUNCEMENT - GNAT 3.13p availability
@ 2000-08-08  0:00  1% Bernard Banner
  0 siblings, 0 replies; 41+ results
From: Bernard Banner @ 2000-08-08  0:00 UTC (permalink / raw)
  To: comp.lang.ada


           Announcing GNAT version 3.13p

Ada Core Technologies announces the availability of version
3.13p of GNAT. This version of GNAT is derived from GNAT
Professional version 3.13a1, and like previous public
versions of GNAT is made freely available with the specific
intention of supporting student use and academic research
use of the Ada 95 language.

The public version of 3.13p is available for the following
targets in binary form:

    Sparc Solaris
    x86 Linux
    Windows 95/98/NT/2000

These versions may be obtained from the usual download
sites for public GNAT releases. Check cs.nyu.edu ftp
directories pub/gnat for details.

The following are new features in version 3.13p

  The package GNAT.Regpat has been enhanced to provide an almost full support
  for Perl-like regular expressions, including several new constructs.

  On unix systems, it is now possible to install GNAT at any location
  without setting any environment variable.

  A warning is issued for the use of Import/Export_Valued_Procedure if
  the default Ada convention is used, since it makes no sense to use
  convention Ada for such a procedure, the only point of the feature
  is to interface with foreign convention procedures. This prevents
  hard to find errors resulting in incorrect behavior at run time.

  A new style switch -gnatyn (STANDARD_CASING in the VMS version) checks
  that all entities from package Standard are cased in a manner consistent
  with the way this package is presented in the Ada Reference Manual.

  A simple way of interfacing with C++ is now documented in the user's
  guide and has been added to the examples directory.

  A new gnatmake switch (-s) causes recompilation of a file if its
  compilation options (e.g. optimization level) have changed.

  A new gnatdll switch (-k) removed Stdcall @nn suffix from the
  import library's exported names.

  A new GNAT library package (GNAT.Float_Control in file g-flocon.ads)
  provides an interface for resetting the floating-point processor into
  the required mode.

  A new GNAT library package (GNAT.Exceptions in file g-except.ads)
  provides a mechanism for raising predefined exceptions with messages
  from Pure units.

  A new pragma, Suppress_Debug_Info, provides for suppressing debugging
  information for selected entities.

  Additional optimization circuits in aggregate handling result in many
  more aggregate assignments being handled in place, instead of generating
  an extra temporary.

  The GNAT Reference manual now contains summary documentation of the GNAT
  library routines. The primary documentation is still in the specs of the
  relevant packages, but the document summarizes what facilities are
  available.

  The package Ada.Strings.Unbounded.Text_IO is now documented in the
  GNAT reference manual.

  A new package Ada.Strings.Wide_Unbounded.Wide_Text_IO has been added
  to provide Wide_Text_IO facilities for Unbounded_Wide_String.

  The -mlongcall switch as well as the __shortcall__ attribute is now provided
  on all powerpc ports. See the GCC documentation for more details.

  The Linker_Options pragma can now take multiple options, which are
  guaranteed to apear in the sequence given in the pragma.

  The gnatbind -E option (stack tracebacks) is now supported under
  Windows NT.

  New switches -gnatwa and -gnatwA are available to turn all
  optional warnings on/off respectively.

  The syntax for the -gnatw warning switch now allows a string of
  options after the w. For example -gnatwaLe turns on all optional
  warnings except elaboration warnings and considers warnings to be
  errors.

  The generated code for many slice assignments has been improved, resulting
  in considerably improved execution time on most targets.

  The generated code for multi-dimensional arrays has been improved,
  significantly improving performance in many situations.

  The compiler now does a much more effective job of suppressing checks
  in array references in loops where the arrays involved are parameters
  that are unconstrained array types, or pointers to unconstrained arrays.

  On VxWorks cross-compilers, a new package called Interfaces.VxWorks provides
  provides a limited binding to the VxWorks API. In particular, it interfaces
  with the VxWorks hardware interrupt facilities.

  The package GNAT.Regexp no longer has any size limitation, and can handle
  complex regular expressions.

  A new warning switch -gnatwc turns on warnings for relational and
  membership operators appearing in statements (e.g. if statements)
  whose results are known at compile time to be always true or
  always false.

  A new pragma Style_Checks allows selection of style checks in a manner
  similar to the existing compiler switch, and also allows the style
  checks to be temporarily turned off and then turned back on again.

  The binary releases now contain the necessary headers to compile the
  C files in the runtime without having to do a full build of GNAT from
  sources.

  Makefile.adalib now also recompiles the C part of the GNAT run time,
  providing the ability to rebuild completely the GNAT libraries with the
  binary distribution.

  Makefile.adalib is now available for cross compilers, as well as the
  native versions of GNAT

  The -gnatwu switch now also provides warnings about possible access to
  uninitialized out parameters.

  The -gnatyk switch (check identifier casing) error messages now contain
  a source location reference to the definition of the relevant identifier.

  It is now permissible to specify the non-default Bit_Order for record
  subtypes. Component clauses for such types must either specify an
  integral number of bytes, or the component must lie entirely within
  one byte. Note that, in accordance with the RM, no reordering of bytes
  is done, the only effect is to renumber bits. This feature is therefore
  only of limited use in dealing with big/little-endian interfacing.

  Default_Bit_Order is now static. This is strictly a violation of the RM
  requirement that it be non-static, but everyone agrees this was a mistake,
  and an AI is expected to "fix" this mistake. Other Ada 95 compilers are
  already consistent with this modified interpreation of the RM.

  Florist has been ported to Solaris 7 and HP-UX 11.00

  GNAT now fully supports HP-UX 11.00, including a dual tasking run time
  that provides access to the DCE run time for compatibility with HP-UX 10.20,
  and to the POSIX pthread run time.

  Interrupt handling on HP-UX has been rewritten to provide a more powerful
  and less restrictive signal handling. In particular, the signals SIGIO and
  SIGPIPE can now be handled via Ada.Interrupts.

  The listing generated by the -gnatR switch now includes alignment values
  for array and record types.

  The NT version of GNAT now generates object files that are fully compatible
  with the standard Microsoft linker, so this linker can be used instead of
  the GNU ld program to build NT executables.

  The default stack size on NT for tasking program has been reduced to 8Mb
  (instead of 32Mb). This increase the default maximum number of tasks
  from approximately 60 to a value around 250.

  The gnathtml tool can now read the list of files to convert from a file,
  eliminating the command line length problem on some systems.

  The parent type of derived types is now recorded in the cross-reference
  section of the ali files. The new ali format is backward compatible with
  the previous one.

  The gnatfind and gnatxref tools have been extended to display the parent
  type of derived types. Furthermore gnatfind is now able to display the full
  type derivation informations for a specific type.

  Shared libraries are now provided as an option (via the -shared gnatbind
  switch) on four additional targets: Solaris x86, Solaris sparc, Linux and
  SCO UnixWare.

  New restrictions No_Implicit_Conditionals and No_Implicit_Loops have
  been added for greater control over generated code. This is particularly
  useful in a safety-critical/certification environment using GNORT (GNAT
  with no run time)

  The performance of the elementary trigononmetric functions has been
  substantially improved.

  A new section has been added to the GNAT Reference Manual providing
  a complete description of the set of representation pragmas and
  pragmas that are accepted by GNAT, and their effect.

  The implementation of the ASIS Data Decomposition Annex is now complete,
  with all queries fully supported.

  More static checking is now done for pragma Restrictions (No_Recursion),
  and most common cases are now detected and flagged as illegalities.

  A new package GNAT.Calendar is provided. It deals with Hour, Minute,
  Seconds, Day_Of_Week, Day_In_Year, Week_In_Year. There is also two
  functions to do conversions between Duration and C timeval struct.

  A new package GNAT.Calendar.Time_IO is provided. This package implements
  formatted output of Ada.Calendar.Time. The format string uses a format
  similar to the one used by the date UNIX command.

  The gnatdll tool now accepts the -I switch to search source and
  object files in specified directories.

  The optimization of checks has been significantly improved, and many
  unnecessary checks, particularly in connection with type conversions and
  the use of the pos operator, have been removed.

  The traceback stored in the exception occurrence (using the gnatbind -E
  switch) now gives accurate values in the case of a reraise.

  The structure used to hold task data has been split to allow restricted
  tasking implementations to use less storage for each task created.

  Enumeration representation clauses for types derived from Boolean
  are now fully supported.

  Variable shift instructions are now generated for multiplications or
  divisions by powers of 2 (e.g. x * 2 ** y, where y is Natural).

  External symbol names and debugging symbols are now more fully qualified.
  This avoids some peculiar naming conflicts for example in the case where
  there is a child package and nested package with the same name, and also
  improves the behavior of gdb when fully qualified names are given.

  An extended form of the Source_File_Name pragma permits handling the
  unusual case where a subunit and child unit have identical qualified
  names. This is unusual, but is allowed by the rules of the language,
  although both versions cannot appear in a single partition.

  The OpenVMS version of GNAT now fully supports the use of mixed-case
  external names. This solves a number of compatibility problems in
  this area, which could show up as unexpected duplicate names.

  A new pragma External_Name_Casing is provided for controlling the
  casing of external names. This is primarily for use in OpenVMS systems,
  but is available in all implementations.

  A new pragma Extensions_Allowed (ON | OFF) is provided for local control
  of whether language extensions are allowed. This pragma may also be used
  as a configuration pragma (e.g. in the gnat.adc file) to control the use
  of extensions for a series of compilations.

  The -gnatwu flag now separately checks specs to make sure that a with in
  a spec is now actually used in the spec. If the with is used only in the
  body, the warning suggests moving it to the body.

  The renaming of a constant was implemented as the declaration of a local
  variable whose initial value was the constant being renamed. This avoids
  an indirection, but is inefficient if the constant being renamed is large.
  This optimization is now restricted to objects that fit in registers.








^ permalink raw reply	[relevance 1%]

* Re: Announcing GNAT version 3.13
  @ 2000-03-15  0:00  1% ` Robert Dewar
  0 siblings, 0 replies; 41+ results
From: Robert Dewar @ 2000-03-15  0:00 UTC (permalink / raw)


NEW FEATURES IN GNAT 3.13

GNAT version 3.13 includes the first release of GLIDE, the
new integrated development environment that builds on and
extends our previous tools work.  GLIDE provides a fully
integrated editor and debugger environment, and supports
multiple graphical debuggers, including a new improved gdbtk
and a version of ddd adapted for use with GNAT.

  The GLIDE editor (based on ada-mode for Emacs)
  includes many new features.  Among them are:

    Gnatdist configuration files are automatically edited
    in Ada-mode.

    Support for big projects with hundreds of directories
    by getting rid of the command line length limit on some
    systems, as well as easier ways to enter a long list of
    directories in the project file.

    The cross-references to and within the standard runtime
    are automatically handled.

    Full contextual menus are provided with the right mouse
    button.

    Multiple exception files for automatic casing can now
    be specified, for instance one system-wide, one
    project-wide and a user-specific one.

    The project file editor is displayed through tabbed
    dialogs, with full contextual help on the fields.

    Indentation is now easier to configure since the
    ada-mode can explain which variable was used to
    indent a specific line.

Under unix systems, it is now possible to install GNAT at
any location without setting any environment variable.

A warning is issued for the use of
Import/Export_Valued_Procedure if the default Ada convention
is used, since it makes no sense to use convention Ada for
such a procedure, the only point of the feature is to
interface with foreign convention procedures.  This prevents
hard to find errors resulting in incorrect behavior at run
time.

A new style switch -gnatyn (STANDARD_CASING in the VMS
version) checks that all entities from package Standard are
cased in a manner consistent with the way this package is
presented in the Ada Reference Manual.

A simple way of interfacing with c++ is now documented in
the user's guide and has been added to the examples
directory.

A new gnatmake switch (-s) causes recompilation of a file if
its compilation options (e.g.  optimization level) have
changed.

A new gnatdll switch (-k) removed Stdcall @nn suffix from
the import library's exported names.

A new GNAT library package (GNAT.Float_Control in file
g-flocon.ads) provides an interface for resetting the
floating-point processor into the required mode.

A new GNAT library package (GNAT.Exceptions in file
g-except.ads) provides a mechanism for raising predefined
exceptions with messages from Pure units.

A new pragma, Suppress_Debug_Info, provides for suppressing
debugging information for selected entities.

Additional optimization circuits in aggregate handling
result in many more aggregate assignments being handled in
place, instead of generating an extra temporary.

The GNAT Reference manual now contains summary documentation
of the GNAT library routines.  The primary documentation is
still in the specs of the relevant packages, but the
document summarizes what facilities are available.

The package Ada.Strings.Unbounded.Text_IO is now documented
in the GNAT reference manual.

A new package Ada.Strings.Wide_Unbounded.Wide_Text_IO has
been added to provide Wide_Text_IO facilities for
Unbounded_Wide_String.

The -mlongcall switch as well as the __shortcall__ attribute
is now provided on all powerpc ports.  See the GCC
documentation for more details.

The Linker_Options pragma can now take multiple options,
which are guaranteed to apear in the sequence given in the
pragma.

The gnatbind -E option (stack tracebacks) is now supported
under Windows ix86.

New switches -gnatwa and -gnatwA are available to turn all
optional warnings on/off respectively.

The syntax for the -gnatw warning switch now allows a string
of options after the w. For example -gnatwaLe turns on all
optional warnings except elaboration warnings and considers
warnings to be errors.

The generated code for many slice assignments has been
improved, resulting in considerably improved execution time
on most targets.

The generated code for multi-dimensional arrays has been
improved, significantly improving performance in many
situations.

The compiler now does a much more effective job of
suppressing checks in array references in loops where the
arrays involved are parameters that are unconstrained array
types, or pointers to unconstrained arrays.

On VxWorks cross-compilers, a new package called
Interfaces.VxWorks provides provides a limited binding to
the VxWorks API.  In particular, it interfaces with the
VxWorks hardware interrupt facilities.

The package GNAT.Regexp no longer has any size limitation,
and can handle complex regular expressions.

A new warning switch -gnatwc turns on warnings for
relational and membership operators appearing in statements
(e.g.  if statements) whose results are known at compile
time to be always true or always false.

A new pragma Style_Checks allows selection of style checks
in a manner similar to the existing compiler switch, and
also allows the style checks to be temporarily turned off
and then turned back on again.

The binary releases now contain the necessary headers to
compile the C files in the runtime without having to do a
full build of GNAT from sources.

Makefile.adalib now also recompiles the C part of the GNAT
run time, providing the ability to rebuild completely the
GNAT libraries with the binary distribution.

Makefile.adalib is now available for cross compilers, as
well as the native versions of GNAT

The -gnatwu switch now also provides warnings about possible
access to uninitialized out parameters.

The -gnatyk switch (check identifier casing) error messages
now contain a source location reference to the definition of
the relevant identifier.

It is now permissible to specify the non-default Bit_Order
for record subtypes.  Component clauses for such types must
either specify an integral number of bytes, or the component
must lie entirely within one byte.  Note that, in accordance
with the RM, no reordering of bytes is done, the only effect
is to renumber bits.  This feature is therefore only of
limited use in dealing with big/little-endian interfacing.

Default_Bit_Order is now static.  This is strictly a
violation of the RM requirement that it be non-static, but
everyone agrees this was a mistake, and an AI is expected to
"fix" this mistake.  Other Ada 95 compilers are already
consistent with this modified interpreation of the RM.

Florist has been ported to Solaris 7 and HP-UX 11.00

GNAT now fully supports HP-UX 11.00, including a dual
tasking run time that provides access to the DCE run time
for compatibility with HP-UX 10.20, and to the POSIX pthread
run time.

Interrupt handling on HP-UX has been rewritten to provide a
more powerful and less restrictive signal handling.  In
particular, the signals SIGIO and SIGPIPE can now be handled
via Ada.Interrupts.

The listing generated by the -gnatR switch now includes
alignment values for array and record types.

The NT version of GNAT now generates object files that are
fully compatible with the standard Microsoft linker, so this
linker can be used instead of the GNU ld program to build NT
executables.

The default stack size on NT for tasking program has been
reduced to 8Mb (instead of 32Mb).  This increase the default
maximum number of tasks from approximately 60 to a value
around 250.

The gnathtml tool can now read the list of files to convert
from a file, eliminating the command line length problem on
some systems.

The parent type of derived types is now recorded in the
cross-reference section of the ali files.  The new ali
format is backward compatible with the previous one.

The gnatfind and gnatxref tools have been extended to
display the parent type of derived types.  Furthermore
gnatfind is now able to display the full type derivation
informations for a specific type.

Shared libraries are now provided as an option (via the
-shared gnatbind switch) on four additional targets:
Solaris x86, Solaris sparc, Linux and SCO UnixWare.

New restrictions No_Implicit_Conditionals and
No_Implicit_Loops have been added for greater control over
generated code.  This is particularly useful in a
safety-critical/certification environment using GNORT (GNAT
with no run time)

The performance of the elementary trigononmetric functions
has been substantially improved.

A new section has been added to the GNAT Reference Manual
providing a complete description of the set of
representation pragmas and pragmas that are accepted by
GNAT, and their effect.

The implementation of the ASIS Data Decomposition Annex is
now complete, with all queries fully supported.

More static checking is now done for pragma Restrictions
(No_Recursion), and most common cases are now detected and
flagged as illegalities.

A new package GNAT.Calendar is provided.  It deals with
Hour, Minute, Seconds, Day_Of_Week, Day_In_Year,
Week_In_Year.  There is also two functions to do conversions
between Duration and C timeval struct.

A new package GNAT.Calendar.Time_IO is provided.  This
package implements formatted output of Ada.Calendar.Time.
The format string uses a format similar to the one used by
the date UNIX command.

The gnatchop utility now recognizes and respect existing
source reference pragmas that it finds in the input file, so
that the output files always properly reflect the original
source file.

The gnatdll tool now accepts the -I switch to search source
and object files in specified directories.

The optimization of checks has been significantly improved,
and many unnecessary checks, particularly in connection with
type conversions and the use of the pos operator, have been
removed.

The traceback stored in the exception occurrence (using the
gnatbind -E switch) now gives accurate values in the case of
a reraise.

The structure used to hold task data has been split to allow
restricted tasking implementations to use less storage for
each task created.

Enumeration representation clauses for types derived from
Boolean are now fully supported.

Variable shift instructions are now generated for
multiplications or divisions by powers of 2 (e.g.  x * 2 **
y, where y is Natural).

External symbol names and debugging symbols are now more
fully qualified.  This avoids some peculiar naming conflicts
for example in the case where there is a child package and
nested package with the same name, and also improves the
behavior of gdb when fully qualified names are given.

An extended form of the Source_File_Name pragma permits
handling the unusual case where a subunit and child unit
have identical qualified names.  This is unusual, but is
allowed by the rules of the language, although both versions
cannot appear in a single partition.

The OpenVMS version of GNAT now fully supports the use of
mixed-case external names.  This solves a number of
compatibility problems in this area, which could show up as
unexpected duplicate names.

A new pragma External_Name_Casing is provided for
controlling the casing of external names.  This is primarily
for use in OpenVMS systems, but is available in all
implementations.

A new pragma Extensions_Allowed (ON | OFF) is provided for
local control of whether language extensions are allowed.
This pragma may also be used as a configuration pragma (e.g.
in the gnat.adc file) to control the use of extensions for a
series of compilations.

The -gnatwu flag now separately checks specs to make sure
that a with in a spec is now actually used in the spec.  If
the with is used only in the body, the warning suggests
moving it to the body.




Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[relevance 1%]

* Re: Project: Free OS and Other Projects Continued
  @ 2000-01-16  0:00  6%   ` Vladimir Olensky
  0 siblings, 0 replies; 41+ results
From: Vladimir Olensky @ 2000-01-16  0:00 UTC (permalink / raw)


Ehud Lamm wrote in message ...
>On Sat, 15 Jan 2000, Michael Garrett wrote:
>|What about an application like the Visual Basic IDE or Symantec's Visual
>|Cafe
>
>As a general direction this seems to me like a very worthy goal.
>
>I also like some of the speicifc ideas (like patterns, and componoent
>lib).



Many interesting ideas are implemented in the Oberon BlackBox
RAD environment. And their implementation is very well described
in the documentation.
Have a look at at http://www.oberon.ch/prod/BlackBox/

As far as component lib is concerned I think that a general purpose
communication class library (IO subsystem) which include all available
means of communications ( IPC, COMMs, sockets, set of available for
use protocols )  and which is very easy to use could be very
useful especially for control applications that consist of several
parts running separately.

I just finished such library for Named Pipes under Windows NT (now
only Sync Blocking Pipes) and going to implements mailslots,
memory mapped files, overlapped operations  ( depending on the
available time). There exists also nice serial IO package
that was posted here some time ago by someone (I do not
remember the author name and it was not mentioned in the
package info).

Below  is a small example of how simple could  be  use of
WinNT Named Pipes with such class library:

------------------------
-- Simple  Echo Server:
----------------------
with Ada.Strings.Unbounded;
use Ada.Strings.Unbounded;
with Ada.Strings.Unbounded.Text_IO;
use Ada.Strings.Unbounded.Text_IO;

procedure tst_Serv_Pipe is

   sPipe : Server_Sync_Pipe_Type;
   str : Unbounded_String;
begin
    Main_Server_Loop:
    loop
       Put_Line(To_Unbounded_String("Waiting for client connection...") );
       Open_Pipe(pipe =>sPipe);
       loop
         begin
            Read_Pipe(sPipe,str);
            Put(To_Unbounded_String("Client command > "));
            Put_Line(str);
            if (str="exit") or (str="exit1") or (str="exit2") then
               Write_Pipe(sPipe, str );
               exit Main_Server_Loop;
            end if;
            Write_Pipe(sPipe, str );
         exception
            when Pipe_Disconnected_Exception =>
                  Put_Line(Null_Unbounded_String);
                  Put_Line(To_Unbounded_String(" --
Pipe_Is_Broken_Exception --"));
                  exit;
           when others    => exit Main_Server_Loop;
         end;
       end loop;
    end loop Main_Server_Loop;
    Close_Pipe(sPipe);

end tst_Serv_Pipe;

-------------------------------------------------
-- Simple Client example:
--------------------------------------
with Win_IPC.Simple_Named_Pipes;
use Win_IPC.Simple_Named_Pipes;
with Ada.Strings.Unbounded;
use Ada.Strings.Unbounded;
with Ada.Strings.Unbounded.Text_IO;
use Ada.Strings.Unbounded.Text_IO;

procedure tst_Client_Pipe is

sPipe : Client_Sync_Pipe_Type;
str : Unbounded_String;

begin

    Put(To_Unbounded_String("type server name -> "));
    str:=Get_Line;

    if str = "" then
       Open_Pipe(pipe => sPipe);
    else
       Open_Pipe(pipe => sPipe, Server_Name => To_String(str));
    end if;

   loop

        Put(To_Unbounded_String("Input_line  > "));
        str:=Get_Line;

       if str="quit" then
          exit;
        end if;

        Write_Pipe(sPipe,str);
        Read_Pipe(sPipe,str);
        Put_Line("Server echo : " & str);

        if    str="exit1" then
           Read_Pipe(sPipe,str);

        elsif  str="exit2" then
           Put(To_Unbounded_String("Type something  > "));
           str:=Get_Line;

           Write_Pipe(sPipe,str);

        elsif
           str="exit" then exit;

        end if;

    end loop;

    Close_Pipe(sPipe);

end tst_Client_Pipe;

---------------------------------------------
-- Another Pipe Client example
----------------------------------------------
 with Win_IPC.Simple_Named_Pipes;
use Win_IPC.Simple_Named_Pipes;
with Ada.Strings.Unbounded;
use Ada.Strings.Unbounded;
with Ada.Strings.Unbounded.Text_IO;
use Ada.Strings.Unbounded.Text_IO;

procedure tst_Call_Pipe is

  In_Msg,
  Out_Msg : Unbounded_String;

  Server_Name : Unbounded_String;

begin
    Put(To_Unbounded_String("type server name -> "));
    Server_Name := Get_Line;

    if Server_Name = "" then
       Server_Name := To_Unbounded_String(".");
    end if;

    loop
        Put(To_Unbounded_String("Input_line      > "));
        In_Msg:=Get_Line;

        if In_Msg="quit" then
           exit;
        end if;

        Call_Pipe (
            Server_Name => To_String ( Server_Name ),
            In_Msg      => In_Msg,
            Out_Msg     => Out_Msg);

       Put_Line (To_Unbounded_String("Server Response : ") & Out_Msg );

    end loop;

end tst_Call_Pipe;


---------------------------------------------


Regards,
Vladimir Olensky








^ permalink raw reply	[relevance 6%]

* Re: [newbie] Need som feedback on code snip
  1999-10-22  0:00  7% ` Robert I. Eachus
@ 1999-10-24  0:00  5%   ` Preben Randhol
  0 siblings, 0 replies; 41+ results
From: Preben Randhol @ 1999-10-24  0:00 UTC (permalink / raw)


"Robert I. Eachus" <eachus@mitre.org> writes:

|   Can I take this one?  Can I?  Can I please... ;-)

Take what? Sorry I don't understand.
 
|    Unbounded strings do for you all that ugly pointer and memory
| allocation and reclamation stuff that you have to worry about in C. 
| And,
| if you are using GNAT, there is a package Ada.Strings.Unbounded.Text_IO,
| that makes it still easier:

Ah thanks.

Thanks to everybody for replying!

The reason that I used aliased was that I wanted to see how it
worked. I agree that one should not use it for this simple example
though. Sorry for not commenting it.
-- 
Preben Randhol                 Affliction is enamoured of thy parts, 
[randhol@pvv.org]              And thou art wedded to calamity. 
[http://www.pvv.org/~randhol/]                    -- W. Shakespeare 




^ permalink raw reply	[relevance 5%]

* Re: [newbie] Need som feedback on code snip
  @ 1999-10-22  0:00  7% ` Robert I. Eachus
  1999-10-24  0:00  5%   ` Preben Randhol
  0 siblings, 1 reply; 41+ results
From: Robert I. Eachus @ 1999-10-22  0:00 UTC (permalink / raw)


  Can I take this one?  Can I?  Can I please... ;-)

Preben Randhol wrote:
  
> I wondered if somebody could take a peep at the code snip below and
> comment on it.

  It works way too hard to do something which is very simple...

> It works, but is is the Right Way to do it or is there
> a smarter way.

-- Just a small test to see how I can change the content of a string
-- variable when I do not know the length of the new or old text.

with Text_IO; use Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
 
procedure My_Test is
   Text :  Unbounded_String := To_Unbounded_String("Hello world!");
begin
   Put_Line(To_String(Text));
   Text := To_Unbounded_String("Hello yourself!");
   Put_Line(To_String(Text));
end My_Test;

   Unbounded strings do for you all that ugly pointer and memory
allocation and reclamation stuff that you have to worry about in C. 
And,
if you are using GNAT, there is a package Ada.Strings.Unbounded.Text_IO,
that makes it still easier:

with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO;
procedure Test2 is
   Text: Unbounded_String := To_Unbounded_String("Hello world!");
begin
   Put_Line(Text);
   Text := To_Unbounded_String("Hello yourself!");
   Put_Line(Text);
end Test2;
 
-- 

                                        Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...




^ permalink raw reply	[relevance 7%]

* Re: Unbounded string deallocation
  1999-08-29  0:00  5%         ` Robert Dewar
@ 1999-08-30  0:00  0%           ` Marin David Condic
  1999-08-30  0:00  0%             ` Robert Dewar
  0 siblings, 1 reply; 41+ results
From: Marin David Condic @ 1999-08-30  0:00 UTC (permalink / raw)


Robert Dewar wrote:

> In article <37C56E59.218CA190@pwfl.com>,
>   e108678@pwflcom wrote:
>  And if Text_IO and some other basic things had Unbounded_String
> > alternatives, you wouldn't even need these calls.
>
> Note the package Ada.Strings.Unbounded.Text_IO
> in GNAT!

Very nice. However it is clearly not a part of the language standard, so
if you need portability for some reason, this might be a problem. It
seems like something that ought to be included in a future version of
Ada since for a large number of plain vanilla apps, unbounded strings
are far more convenient where speed is not an issue. (For example,
something that implements a command line interpreter as its only real
use of strings)

MDC
--
Marin David Condic
Real Time & Embedded Systems, Propulsion Systems Analysis
United Technologies, Pratt & Whitney, Large Military Engines
M/S 731-95, P.O.B. 109600, West Palm Beach, FL, 33410-9600
***To reply, remove "bogon" from the domain name.***

Visit my web page at: http://www.mcondic.com/






^ permalink raw reply	[relevance 0%]

* Re: Unbounded string deallocation
  1999-08-30  0:00  0%           ` Marin David Condic
@ 1999-08-30  0:00  0%             ` Robert Dewar
  0 siblings, 0 replies; 41+ results
From: Robert Dewar @ 1999-08-30  0:00 UTC (permalink / raw)


In article <37CA8ABF.21F6F177@pwfl.com>,
  e108678@pwflcom wrote:
> Robert Dewar wrote:
>
> > In article <37C56E59.218CA190@pwfl.com>,
> >   e108678@pwflcom wrote:
> >  And if Text_IO and some other basic things had
Unbounded_String
> > > alternatives, you wouldn't even need these calls.
> >
> > Note the package Ada.Strings.Unbounded.Text_IO
> > in GNAT!
>
> Very nice. However it is clearly not a part of the language
standard, so
> if you need portability for some reason, this might be a
problem.

It is of course provided in all versions of GNAT, so it is
fully portable across all GNAT platforms. Generally when we
make something a grandchild in Ada, rather than making it
a child of GNAT, we are suggesting that we think it is a
reasonable addition for other vendors to copy (this is much
more relevant than worrying about the next version of the
standard which, if it appears, is many years away).

Robert Dewar
Ada Core Technologies


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




^ permalink raw reply	[relevance 0%]

* Re: Unbounded string deallocation
  @ 1999-08-29  0:00  5%         ` Robert Dewar
  1999-08-30  0:00  0%           ` Marin David Condic
  0 siblings, 1 reply; 41+ results
From: Robert Dewar @ 1999-08-29  0:00 UTC (permalink / raw)


In article <37C56E59.218CA190@pwfl.com>,
  e108678@pwflcom wrote:
 And if Text_IO and some other basic things had Unbounded_String
> alternatives, you wouldn't even need these calls.

Note the package Ada.Strings.Unbounded.Text_IO
in GNAT!

Robert Dewar
Ada Core Technologies


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




^ permalink raw reply	[relevance 5%]

* Re: Sequential???
  @ 1999-01-23  0:00  3% ` Matthew Heaney
  0 siblings, 0 replies; 41+ results
From: Matthew Heaney @ 1999-01-23  0:00 UTC (permalink / raw)


joelngstn@aol.com (JoeLngstn) writes:

> My college Ada professor recently showed us some simple examples of string
> handling in which we used ada.text_io.get_line to get both the string and its
> length. We did this twice, once for first name, and again for last. We had a
> put procedure directly under the code where we got the last name that would
> display the length of the first name. (The first name was declared as
> string(1..10)) When the length of the first name was equal to ten, it would
> display that value before prompting for the last name, in effect, running the
> program out of order. Can anyone explain?
> 
> If needed I will supply an example of source code that causes this.

This is a very subtle feature of Get_Line, that at first blush may seem
confusing.  But it really does make sense once explained.  Read on.

The issue is that Get_Line reads into a fixed size buffer.  What if the
input is longer than (or equal in size to) the size of the buffer?

You can read the entire line using multiple invocations of Get_Line, but
somehow Get_Line has to tell you that it has read all of the current
line.  How does it do this?

Consider another, similar problem.  Suppose you have a stream of
integers you want to read in from standard input, like this:

  loop
    Get (N);
    <process N>;
  end loop;

But there's a problem here.  How does this loop terminate?

A standard idiom for this kind of thing is to use a sentinel of some
kind, a special value outside the range of "normal" values, that
indicates that all of the stream has been consumed.

In our example above, we might use the value 0 to indicate that there
are no more values to read.  So our loop now looks like this:

  loop
    Get (N);
    exit when N = 0;
    <process N>;
  end loop;

Now all is well, and the loop terminates when it reads in the value 0.
This scheme works because 0 isn't in the set of values you want to
process.

Back to Get_Line and reading a string.  What we need is a way for
Get_Line to read in a value "outside the range of string," which
indicates to the caller that there is nothing left on the current line.  

It's exactly analogous to our integer stream.  You read in a special
value "outside the range of process-able integers," which indicates to
the caller that there is nothing left in the stream.

In order to read in the entire line, we'd structure our loop like
similar to what we did above, but for a "stream of substrings":

declare
  Line : String (1 .. 10);
  Last : Natural;
begin
  loop
    Get_Line (Line, Last);

    < process Line (1 .. Last) >

    exit when ???;
  end loop;
end;

What is our termination condition?  Is is this: "All text on current
line has consumed" is indicated by the condition "input buffer has some
unused characters."

We can state that termination condition in code as

  Last < Line'Last

Basically, at the point that Get_Line returns fewer characters than
you've allocated in your input buffer, it means all of the current line
has been consumed.

Most of the time you don't have to think about this, because you usually
allocate a larger buffer than you'll ever need.  That's why an input
buffer is typically 80 or 132 characters long.

Actually, if you want to be technical, you'll want to allocate one extra
character --that you know will go unused-- so that you can consume all
on the input using a single invocation of Get_Line.  So technically,
you should declare an input buffer that is 81 or 133 characters long.

In your example, you allocated a buffer that's 10 characters long:

declare
  Line : String (1 .. 10);
  Last : Natural;
begin
  Get_Line (Line, Last);

Everything is fine and dandy when the input line contains fewer than 10
characters.  And if the input line is longer than 10 characters, it
makes intuitive sense that you have to do more than one fetch, because
your buffer is too small to contain all the input.

The weird case is when the input line contains the same number of
characters as the size of the input buffer.  But remember that there has
to be at least one character in the input buffer that goes unused,
because that is how Get_Line tells you it read all the input.

If the input line is the same length as the input buffer, then you have
to wait until the next Get_Line to learn that "all input on the current
line has been consumed."  The first Get_Line returns all the text on the
line (in your example, the buffer is full with all 10 chars, and Last =
Line'Last), and the second Get_Line returns 0 characters, which tells
you you're done (Last < Line'Last).

That's the technical explanation of why you have a "problem" using
Get_Line.  However, this behavior makes sense once you grok the idea
that you need at least one slot to go unfilled, in order to indicate
that the entire line has been consumed.  (And in your example, every
slot goes unfilled, in the second call to Get_Line.)

Now that you know why, you should be thinking by now, "OK, what do I
need to do."  Here are a few ideas:

1) Decide by fiat that you'll accept a max length line of input.  So
   allocate an input buffer with an extra character:

declare
   Max_Length_Of_Input : constant := 80;
   Line : String (1 .. Max_Length_Of_Input + 1);
   Last : Natural;
begin
   Get_Line (Line, Last);
   < process Line (1 .. Last) >
end;


2) Allow any length as input.  Cache the input substring-at-a-time in an
   unbounded string buffer, and then process that when you've read in
   the entire line:

declare
   Buffer : Unbounded_String;
   Line   : String (1 .. 10);  -- actual length doesn't really matter
   Last   : Natural;
begin
   loop
     Get_Line (Line, Last); 
     Append (Line (1 .. Last), To => Buffer);
     exit when Last < Line'Last;
   end loop;

   <process To_String (Buffer) >
end;


3) If you're using GNAT, then the above algorithm is provided for you:

package Ada.Strings.Unbounded.Text_IO is

   function Get_Line                                return Unbounded_String;
   function Get_Line (File : Ada.Text_IO.File_Type) return Unbounded_String;
   --  Reads up to the end of the current line, returning the result
   --  as an unbounded string of appropriate length. If no File parameter
   --  is present, input is from Current_Input.
...



I hope this clears up the Get_Line mystery.  Post a follow-up if there's
anything that's not clear.

Matt





^ permalink raw reply	[relevance 3%]

* Got me stumped any idea?
@ 1997-10-11  0:00  5% Robert A. Thompson
  0 siblings, 0 replies; 41+ results
From: Robert A. Thompson @ 1997-10-11  0:00 UTC (permalink / raw)



I have been working on some stuff here recently and thought that Ada
would be a good compiler for the job.  Being it three years since I took
the class I thought I could brush up on my Ada, Familiarize myself with
the ada95 compiler we just put on our network, and get my work done. 
(kill three birds with one stone)  Well this little project is killing
three birds and one human.  ( I didn't realize what a couple of years
can do to one's rememberance of ada)  I have gone out on the web
searching for some pointers on ada95 b/c I was having some problems.  

I have this file:

With Ada.Text_IO; Use Ada.Text_IO;
With Ada.Strings.Unbounded; Use Ada.Strings.Unbounded;
Procedure Compare is

File1 		:	File_type;
File2 		:	File_type;
FileOut		:	File_type;
File1_line	:	String(1..80);

Begin
	Open(File1,In_File,"NetView.dat");
	Create(FileOut, Out_File, "Data.dat");
	
	While (Not End_Of_File(File1)) loop
		Get(File1,File1_line);
		Skip_Line(File1);
		Put_Line(FileOut,File1_Line);
		New_Line(FileOut);
	End Loop;

	Close(File1);
	Close(FileOut);
End Compare;

That I was gonna use to compare two files.  I thought I would check it
along the way to make sure I was doing things right.  I kept getting
some errors so as I said I went out onto the web and found some help. 
One of the AdaPages had this piece of code:


with Ada.Strings.Unbounded, Text_IO, Ustrings;
use  Ada.Strings.Unbounded, Text_IO, Ustrings;

procedure Put_Long is
  -- Print "long" text lines
  Input : Unbounded_String;
begin
  while (not End_Of_File) loop
    Get_Line(Input);
    if Length(Input) > 10 then
      Put_Line(Input);
    end if;
  end loop;
end Put_Long;



I thought it would be perfect..and looked exactly like what I needed.  I
couldn't compile it though.  It would keep giving me errors saying that
I was not passing the right paramters through the Get_line

Get_Line(File1,File1_line);

I corrected this with a Get

Get(File1,File1_line);

Now when I get the lines in and write them out from a simple text file. 
It goes to printing the lines strange into the file almost like

item1       blah blah
    item1       blah blah
        item1       blah blah
            item1       blah blah ....

This goes on untill it eventually wraps around I have yet to figure out
any of these.  problems


IF some one could let me in on why it is giving me these errors, and
evidently tell me what i am forgetting about basic file I/O I would
greatly Appreciate it.

Sincerely,

Robert A. Thompson




^ permalink raw reply	[relevance 5%]

* Re: Reading a line of arbitrary length
  @ 1997-02-17  0:00  5%       ` Robert Dewar
  0 siblings, 0 replies; 41+ results
From: Robert Dewar @ 1997-02-17  0:00 UTC (permalink / raw)



Matthew said

<<Yes, it's true the heap is being implicitly allocated behind the scenes,
and that is exactly where I prefer to keep it.  In general, messing with
heap is dangerous business.  If it's a toss-up between a solution that
requires explicit heap allocation and a solution that hides that
allocation, then the latter solution wins.

Also, I'm assuming that implementations of Unbounded_String are going to
make heap-space allocation optimizations that won't necessarily apply to
using the new operator directly.>>

Of course in GNAT, the *entire* operation of reading a variable length
string is behind the scenes. A programmer using GNAT version 3.10 merely
writes:

with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO;

...

    S : Unbounded_String := Get_Line (file);

and that's the end of it.





^ permalink raw reply	[relevance 5%]

* Re: Reading a line of arbitrary length
  @ 1997-02-12  0:00  5% ` Robert Dewar
    1 sibling, 0 replies; 41+ results
From: Robert Dewar @ 1997-02-12  0:00 UTC (permalink / raw)




Thomas asks

<<Get_Line only works on Strings, not Unbounded_Strings.  Would I need
to read in chunks of fixed length, then paste them together?>>

That's right. In GNAT 3.10, there is a child package 
Ada.Strings.Unbounded.Text_IO that provides Get and Put procedures
for unbounded strings.





^ permalink raw reply	[relevance 5%]

* Simplifying Unbounded_Stri
@ 1995-03-19 13:37  6% David Wheeler
  0 siblings, 0 replies; 41+ results
From: David Wheeler @ 1995-03-19 13:37 UTC (permalink / raw)



I'm looking for some advice on how to simplify Unbounded_String
handling. Discussion and source code follows.



As many of you know I've developed a tutorial on Ada 95, and I've
been developing an expanded version.  Since the Ada 83 "String"
type involves all sorts of convolutions when you want to vary its
length, I've decided that it'd be better to teach about
Unbounded_String first.

However, I think Unbounded_String is a little clumsy to use as-is.
For example, there isn't a Text IO package for it (as far as I can tell)!
No problem, that's easy to create.
However, there's also no way to declare Unbounded_String constants..
I have to keep using To_Unbounded_String("text").
Also, while the type Unbounded_String and the package name
Ada.Strings.Unbounded are very descriptive,
they are too darn long for names used all over the place.

I've decided that I want to create a single package that simplifies
a user's life.  I want to create a package "Ustrings"
that provides the subtype Ustring, all the operations
of Ada.Strings.Unbounded and some Text_IO types of operations.

There are only two ways I've found to do this, and I'm
not entirely happy with either:
 1. Using cut & paste, paste in all the declarations from the other
    packages and then rename each one. Yuk.  What I'd like to do
    is put a "use-like" clause in the package and have it be
    re-exported, but I don't think I can do that.. can I?
 2. Create a child package of Ada.Strings.Unbounded, add what I want,
    and then create "Ustrings" by declaring it to be a rename of
    that child.  That looks much nicer, but I'm concerned that some
    compilers may not like me creating a child of a predefined package.

Any suggestions, improvements, comments?
Code samples follow; suggestions appreciated.

--- David A. Wheeler
Net address: wheeler@ida.org

==============================================================

METHOD 1:


with Ada.Strings.Unbounded, Unbounded_String_Text_IO;
use  Ada.Strings.Unbounded, Unbounded_String_Text_IO;

package Ustrings is

 -- This package provides a simpler way to work with type
 -- Unbounded_String, since this type will be used very often.
 --
 -- This package the following simplifications:
 --  + Shortens package name to "Ustrings" and type name to "Ustring".
 --  + Combines Ada.Strings.Unbounded and Unbounded_String_Text_IO
 --    into a single package.
 --  + Creates shorter function names for To_Unbounded_String, i.e.
 --    To_Ustring(U) and U(S).  "U" is not a very readable name, but
 --    it's such a common operation that a short name seems appropriate
 --    (this function is needed every time a String constant is used).
 -- Developed by David A. Wheeler; released to the public domain.

 subtype Ustring is Unbounded_String;

 function To_Ustring(Source : String) return Unbounded_String
                                       renames To_Unbounded_String;
 function U(Source : String)          return Unbounded_String
                                       renames To_Unbounded_String;


 -- Include all declarations from packages
 --  Ada.Strings.Unbounded and Unbounded_String_Text_IO.

 -- These "use" clauses don't do the job, but creating a mass of
 -- "rename"s is awkward:

 use Ada.Strings.Unbounded;
 use Unbounded_String_Text_IO;

end Ustrings;


===========================================================
METHOD 2:


with Ada.Strings.Unbounded.Simplified;
package Ustrings renames Ada.Strings.Unbounded.Simplified;


with Unbounded_String_Text_IO, Text_IO;
use  Unbounded_String_Text_IO, Text_IO;

package Ada.Strings.Unbounded.Simplified is

 -- This package provides a simpler way to work with type
 -- Unbounded_String, since this type will be used very often.
 --
 -- This package the following simplifications:
 --  + Shortens package name to "Ustrings" and type name to "Ustring".
 --  + Combines Ada.Strings.Unbounded and Unbounded_String_Text_IO
 --    into a single package.
 --  + Creates shorter function names for To_Unbounded_String, i.e.
 --    To_Ustring(U) and U(S).  "U" is not a very readable name, but
 --    it's such a common operation that a short name seems appropriate
 --    (this function is needed every time a String constant is used).
 -- Developed by David A. Wheeler; released to the public domain.

 subtype Ustring is Unbounded_String;

 function To_Ustring(Source : String) return Unbounded_String
                                       renames To_Unbounded_String;
 function U(Source : String)          return Unbounded_String
                                       renames To_Unbounded_String;


 -- Include all declarations from packages
 --  Ada.Strings.Unbounded and Unbounded_String_Text_IO.

  procedure Get_Line(File : in File_Type; Item : out Unbounded_String)
            renames Get_Line;
  procedure Get_Line(Item : out Unbounded_String)
            renames Get_Line;

  procedure Put(File : in File_Type; Item : in Unbounded_String)
            renames Put;
  procedure Put(Item : in Unbounded_String)
            renames Put;

  procedure Put_Line(File : in File_Type; Item : in Unbounded_String)
            renames Put_Line;
  procedure Put_Line(Item : in Unbounded_String)
            renames Put_Line;

end Ada.Strings.Unbounded.Simplified;



with Ada.Strings.Unbounded, Text_IO;
use  Ada.Strings.Unbounded, Text_IO;
package Unbounded_String_Text_IO is
  procedure Get_Line(File : in File_Type; Item : out Unbounded_String);
  procedure Get_Line(Item : out Unbounded_String);

  procedure Put(File : in File_Type; Item : in Unbounded_String);
  procedure Put(Item : in Unbounded_String);

  procedure Put_Line(File : in File_Type; Item : in Unbounded_String);
  procedure Put_Line(Item : in Unbounded_String);
end Unbounded_String_Text_IO;






^ permalink raw reply	[relevance 6%]

Results 1-41 of 41 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
1995-03-19 13:37  6% Simplifying Unbounded_Stri David Wheeler
1997-02-12  0:00     Reading a line of arbitrary length Thomas Koenig
1997-02-12  0:00  5% ` Robert Dewar
1997-02-16  0:00     ` Matthew Heaney
1997-02-16  0:00       ` Robert Dewar
1997-02-16  0:00         ` Matthew Heaney
1997-02-17  0:00  5%       ` Robert Dewar
1997-10-11  0:00  5% Got me stumped any idea? Robert A. Thompson
1999-01-23  0:00     Sequential??? JoeLngstn
1999-01-23  0:00  3% ` Sequential??? Matthew Heaney
1999-08-25  0:00     Unbounded string deallocation Andy Askey
1999-08-25  0:00     ` Martin C. Carlisle
1999-08-26  0:00       ` Andy Askey
     [not found]         ` <37c552fd@news1.us.ibm.net>
1999-08-26  0:00           ` Marin David Condic
1999-08-29  0:00  5%         ` Robert Dewar
1999-08-30  0:00  0%           ` Marin David Condic
1999-08-30  0:00  0%             ` Robert Dewar
1999-10-22  0:00     [newbie] Need som feedback on code snip Preben Randhol
1999-10-22  0:00  7% ` Robert I. Eachus
1999-10-24  0:00  5%   ` Preben Randhol
2000-01-15  0:00     Project: Free OS and Other Projects Continued Michael Garrett
2000-01-15  0:00     ` Ehud Lamm
2000-01-16  0:00  6%   ` Vladimir Olensky
2000-03-15  0:00     Announcing GNAT version 3.13 Robert Dewar
2000-03-15  0:00  1% ` Robert Dewar
2000-08-08  0:00  1% ANNOUNCEMENT - GNAT 3.13p availability Bernard Banner
2000-12-30  7:33     Newbie Questions about Get, Get_Line gressett
2000-12-30 17:09     ` Ted Dennison
2000-12-31  8:13       ` gressett
2000-12-31 17:03  6%     ` Robert Dewar
2001-03-05 17:03  6% How do I free unbounded strings? Erik Sigra
2001-11-26  9:45     string input kotee
2001-11-27  4:05     ` Robert Dewar
2001-11-27  6:25  4%   ` Mark Lundquist
2001-11-27  9:33  0%     ` Lutz Donnerhacke
2001-12-11  9:33     Ada2005 Peter Hermann
2001-12-12 11:29     ` Ada2005 Peter Hermann
2001-12-12 12:59       ` Ada2005 Carsten Freining
2001-12-12 14:40         ` Ada2005 Peter Hermann
2001-12-12 15:16           ` Ada2005 Ted Dennison
2001-12-12 18:14  4%         ` Ada2005 Mark Lundquist
2001-12-12 18:40  0%           ` Ada2005 Ted Dennison
2001-12-12 19:12  0%             ` Ada2005 Mark Lundquist
2002-10-29 20:24     Get_Line Justin Birtwell
2002-10-30  1:30     ` Get_Line Jeffrey Carter
2002-10-30 13:33       ` Get_Line Justin Birtwell
2002-10-30 18:08         ` Get_Line Jeffrey Carter
2002-10-30 22:42           ` Get_Line Robert A Duff
2002-10-31  0:26             ` Get_Line Chad R. Meiners
2002-10-31  0:44               ` Get_Line Robert A Duff
2002-10-31 21:46                 ` Get_Line Chad R. Meiners
2002-11-01 16:59                   ` Get_Line Robert A Duff
2002-11-01 21:04                     ` Get_Line Chad R. Meiners
2002-11-01 23:32  5%                   ` Get_Line Matthew Heaney
2002-11-16 20:07  6% read filename and then open text file Bjoern Schiessle
2003-02-22 22:31  5% strange execution error alfonso acosta
2003-05-26 13:05  5% I/O - exception handling Sergey Koshcheyev
2003-05-26 14:52  0% ` Jean-Pierre Rosen
2003-05-26 16:31  0% ` Steve
2003-05-27  2:36  6% ` Anisimkov
2003-05-27  7:21  0%   ` Sergey Koshcheyev
2003-06-07  8:21  6% Visibility And838N
     [not found]     <009C830A.36D4A463.0015D3EC@netscape.net>
2003-06-07 12:18  0% ` Visibility David C. Hoos, Sr.
2003-07-11 12:05     Computer Language Shootout Craig Carey
2003-07-11 12:50     ` Preben Randhol
2003-07-15 15:15       ` Matthew Heaney
2003-07-15 23:46         ` Robert I. Eachus
2003-07-16  4:37           ` Matthew Heaney
2003-07-16 18:01             ` Robert I. Eachus
2003-07-17  9:38               ` Preben Randhol
2003-07-17 16:29                 ` Wesley Groleau
2003-07-17 17:36                   ` Jean-Pierre Rosen
2003-07-17 21:47                     ` Robert A Duff
2003-07-18 21:22                       ` Pascal Obry
2003-07-19 19:04                         ` Robert A Duff
2003-07-19 23:14  4%                       ` Samuel Tardieu
2003-07-20  0:26  0%                         ` Robert I. Eachus
2004-02-26  9:10     count_string program Cecilia Chew
2004-02-27 13:28  5% ` Stephen Leake
2004-10-21 17:52     variable lenght strings fabio de francesco
2004-10-21 22:42     ` Marius Amado Alves
2004-10-21 23:14       ` Matthew Heaney
2004-10-22  7:38  4%     ` Martin Krischik
2004-10-21 23:05  5% ` Stephen Leake
2010-04-17 13:21     confusion with string initialization brett
2010-04-17 17:42  7% ` 
2011-03-22 23:34     Text parsing package Syntax Issues
2011-03-23  8:32     ` Dmitry A. Kazakov
2011-03-23 11:19  6%   ` Syntax Issues
2014-04-04  0:35  6% gnatmake error I don't understand agent
2014-04-04  4:14  0% ` Per Sandberg
2018-02-21 23:57  5% article on acces types and dynamic serialization in Ada (2003) Mehdi Saada
2020-01-25 21:52     GNATCOLL-Mmap example Bob Goddard
2020-01-28  8:25     ` Dmitry A. Kazakov
2020-01-28 18:53  6%   ` Bob Goddard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox