Re: [Ada] CONSTRAINT_ERROR trying to read a GtkEntry
- From: "Jeffrey Creem" <jeff thecreems com>
- To: "Ruben Porras" <nahoo82 telefonica net>, "lista gtk+" <gtk-list gnome org>
- Subject: Re: [Ada] CONSTRAINT_ERROR trying to read a GtkEntry
- Date: Sat, 4 Jan 2003 00:13:34 -0500
I did not try to run your code or my fix... But off hand I would guess that
replacing the code that says
> procedure Read
> (Object : access Gtk_Button_Record'Class)
> is
> Str : string(1..30);
> begin
>
> Str := Get_Text(Entry1); -- LINE 24
>
> end Read;
with
> (Object : access Gtk_Button_Record'Class)
> is
> Str : string(1..30) := Get_Text(Entry1); -- Get the string here, not
inside the begin
> begin
>
> -- Str := Get_Text(Entry1); -- LINE 24
>
> end Read;
might have something to do with it. You can not assign arrays (strings) to
each other unless they really are exactly the same length. So, unless your
get_Text is always going to return 30 characters (you set max length to 30
but their could be less) you need to store the return value into a string of
the proper size. Doing the get_text call in the variable declaration creates
a string of the "proper" length.
----- Original Message -----
From: "Ruben Porras" <nahoo82 telefonica net>
To: "lista gtk+" <gtk-list gnome org>
Sent: Friday, January 03, 2003 5:50 PM
Subject: [Ada] CONSTRAINT_ERROR trying to read a GtkEntry
> I get a CONSTRAINT_ERROR always I try to read a GtkEntry, as an example,
> the folowing program ends with
>
> raised CONSTRAINT_ERROR : test.adb:24
>
> Piece of code:
>
> with Glib; use Glib;
> with Gtk.Widget; use Gtk.Widget;
> with Gtk.Window; use Gtk.Window;
> with Gtk.Box; use Gtk.Box;
> with Gtk.GEntry; use Gtk.GEntry;
> with Gtk.Button; use Gtk.Button;
> with Gtk.Handlers; use Gtk.Handlers;
> with Gtk.Main;
>
> procedure Test is
>
> Window1 : Gtk_Window;
> Vbox1 : Gtk_Vbox;
> Entry1 : Gtk_Entry;
> Button1 : Gtk_Button;
>
> package Button_Callback is new
> Gtk.Handlers.Callback (Gtk_Button_Record);
> procedure Read
> (Object : access Gtk_Button_Record'Class)
> is
> Str : string(1..30);
> begin
>
> Str := Get_Text(Entry1); -- LINE 24
>
> end Read;
>
> begin
>
> Gtk.Main.Set_Locale;
> Gtk.Main.Init;
>
> Gtk_New(Window1);
> Gtk_New_Vbox (Vbox1, False, 0);
> Add (Window1, Vbox1);
>
> Gtk_New (Entry1);
> Set_Max_Length (Entry1, 30);
> Pack_Start (Vbox1, Entry1, False, False, 0);
>
> Gtk_New (Button1,"Read");
> Button_Callback.Connect
> (Button1, "clicked",
> Button_Callback.To_Marshaller (Read'Access));
> Pack_Start (Vbox1,Button1, False, False, 0);
>
> Show(Entry1);
> Show(Button1);
> Show(VBox1);
> Show(Window1);
>
> Gtk.Main.Main;
> end Test;
>
>
> --
> The chains are broken and the door is open wide
> Our eyes adjusting to the light that was denied
> And bring a sense of wonder
>
> http://www.es.debian.org/intro/about.es.html
>
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]