From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,564a91823edb719c X-Google-Attributes: gid103376,public From: pumilia@est.it Subject: CONTRAINT ERROR (was Re: parsing a string) Date: 2000/01/26 Message-ID: <86mm2o$3cd$1@nnrp1.deja.com>#1/1 X-Deja-AN: 577766843 References: <388095E5.6BF46237@cstc.org> <85q63n$ese$1@bgtnsc01.worldnet.att.net> <86h42s$1ht$1@nnrp1.deja.com> X-Http-Proxy: 1.0 x23.deja.com:80 (Squid/1.1.22) for client 212.239.48.47 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Wed Jan 26 11:33:44 2000 GMT X-MyDeja-Info: XMYDJUIDpumilia Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.7 [en] (X11; I; Linux 2.2.13 i686) Date: 2000-01-26T00:00:00+00:00 List-Id: In article , Stephen Leake 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.