From: pumilia@est.it
Subject: CONTRAINT ERROR (was Re: parsing a string)
Date: 2000/01/26
Date: 2000-01-26T00:00:00+00:00 [thread overview]
Message-ID: <86mm2o$3cd$1@nnrp1.deja.com> (raw)
In-Reply-To: uu2k3kszb.fsf@gsfc.nasa.gov
In article <uu2k3kszb.fsf@gsfc.nasa.gov>,
Stephen Leake <Stephen.Leake@gsfc.nasa.gov> wrote:
> Index is a function, which must be assigned to a value, so this can't
> be the real source. Please include your _complete_ test program, so we
> can compile it ourselves, to help get a good answer.
>
> The default for Map should be fine. You can find out what else you
> might pass for Map in the package Ada.Strings.Maps.
>
> -- Stephe
>
Ok, i simplified my program, adjusted something thanks to David Hoos's
and
your useful comments and found a new error: CONSTRAINT_ERROR.
Here is my test procedure, aimed to converting an unbounded string
to string and then to parse the string:
-- str2_test --------------------------------------
with ada.strings.unbounded;
use ada.strings.unbounded;
with ustrings;
use ustrings;
with text_io;
with Ada.Integer_Text_IO;
use text_io;
with ada.strings.fixed; use ada.strings.fixed;
with Ada.Integer_Text_IO;
use Ada.Integer_Text_IO;
procedure str2_test is
output_file_string : unbounded_string ;
output_file : string (1..25) ;
pos1 : natural;
Begin
get_line(output_file_string);
put(" output: "); put(output_file_string); put("<--"); new_line;
output_file := to_string(output_file_string);
put(" Output: "); put(output_file); put("<--"); new_line;
put(" index: "); pos1 := Index(output_file,"xxx");
put(pos1);
new_line;
end str2_test;
-- str2_test --------------------------------------
While executing i get the error:
> raised constraint_error : str2_test.adb:24
This is line 24:
output_file := to_string(output_file_string);
Any help wil be appreciiated
thank you
Pol
- ustrings.ads ---------------------------------
-- Ideally this would be a child package of "Ada.Strings.Unbounded".
-- package Ustrings is
-- procedure Get_Line(Item : out Unbounded_String);
-- procedure Put(Item : in Unbounded_String);
-- procedure Put_Line(Item : in Unbounded_String);
-- end Ustrings;
--
-- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
-- Author: David A. Wheeler
--
with Text_IO, Ada.Strings.Unbounded;
use Text_IO, Ada.Strings.Unbounded;
package Ustrings is
-- This package provides a simpler way to work with type
-- Unbounded_String, since this type will be used very often.
-- Most users will want to ALSO with "Ada.Strings.Unbounded".
-- Ideally this would be a child package of "Ada.Strings.Unbounded".
--
-- This package provides the following simplifications:
-- + Shortens the type name from "Unbounded_String" to "Ustring".
-- + 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).
-- It also creates S(U) as the reverse of U(S).
-- + Adds other subprograms, currently just "Swap".
-- + Other packages can use this package to provide other
simplifications.
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;
function S(Source : Unbounded_String) return String
renames To_String;
-- "Swap" is important for reuse in some other packages, so we'll
define it.
procedure Swap(Left, Right : in out Unbounded_String);
function Empty(S : Unbounded_String) return Boolean;
-- returns True if Length(S)=0.
pragma Inline(Empty);
-- I/O Routines.
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 Ustrings;
- ustrings.ads ---------------------------------
Sent via Deja.com http://www.deja.com/
Before you buy.
next prev parent reply other threads:[~2000-01-26 0:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-01-15 0:00 parsing a string Paolo M. Pumilia
2000-01-15 0:00 ` James S. Rogers
2000-01-24 0:00 ` pumilia
2000-01-24 0:00 ` pumilia
2000-01-24 0:00 ` Stephen Leake
2000-01-26 0:00 ` pumilia [this message]
2000-01-26 0:00 ` CONTRAINT ERROR (was Re: parsing a string) Ian Clifton
2000-01-26 0:00 ` Roger Racine
2000-01-26 0:00 ` Fraser
2000-01-26 0:00 ` Simon Wright
2000-01-26 0:00 ` John English
2000-01-24 0:00 ` parsing a string Ehud Lamm
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox