comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Strings and errors... (gnat)
Date: Wed, 29 Nov 2006 12:44:58 -0500
Date: 2006-11-29T12:44:58-05:00	[thread overview]
Message-ID: <wccmz6aywo5.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 1164821430.144822.138100@h54g2000cwb.googlegroups.com

"tr00per" <tr00per@o2.pl> writes:

> Hello!
> During compilation GNAT says:
> pracownicy.adb:123:22: warning: too few elements for subtype of
> "Standard.String" defined at line 107
> pracownicy.adb:123:22: warning: "Constraint_Error" will be raised at
> run time
> (and it is raised at run time)
>
> Those lines look like that:
> ...
> 104: 		buf:string(1..70);
> ...
> 107: 		tmp:string(1..30);
> ...
> 123: 		tmp:=buf(13..26);
> ...
>
> 123:22 is after :=
> I don't get the point. Where is the problem? Please help!

You can't assign a shorter string into a longer one -- the lengths have
to match.  You could do:

    tmp: String := buf(13..26);

or

    tmp: constant String := buf(13..26);

and it will take the bounds for tmp from buf(13..26).

Or, you could use Unbounded_Strings.

- Bob



  reply	other threads:[~2006-11-29 17:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-29 17:30 Strings and errors... (gnat) tr00per
2006-11-29 17:44 ` Robert A Duff [this message]
2006-11-29 17:57   ` tr00per
2006-11-29 18:10     ` Ludovic Brenta
2006-11-30 11:36       ` Georg Bauhaus
2006-11-30  2:04   ` jimmaureenrogers
2006-12-01  8:39 ` Martin Krischik
2006-12-01 19:39   ` [solved] tr00per
  -- strict thread matches above, loose matches on Subject: below --
2006-11-29 17:57 Strings and errors... (gnat) Benjamin Place
2006-11-30  6:16 ` Jeffrey R. Carter
replies disabled

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