[gtkada] simple gtk_editable question

Eric Mathieu eric.mathieu at c-s-canada.ca
Wed Jan 9 20:36:55 CET 2002


May be you can try this:  

	name : name_type;

procedure On_Create_Database_Accept_Button_Clicked
      (Object : access Gtk_Button_Record'Class)
   is
     holder : constant string :=
get_chars(Create_Database_D.New_Database_Entry);
    begin
       if holder'length > name'length then
	name(1..40) := holder(holder'first .. holder'first + 39);
       else
	name := (others => ' ');
     	name(1 .. holder'length) := holder(holder'first .. holder'last);
      end if;
      --...
    end;
 -----------------------

Eric Mathieu


> -----Original Message-----
> From: gtkada-admin at lists.act-europe.fr 
> [mailto:gtkada-admin at lists.act-europe.fr]On Behalf Of Clark, G L
> Sent: 9 janvier 2002 14:17
> To: 'gtkada at lists.act-europe.fr'
> Subject: RE: [gtkada] simple gtk_editable question
> 
> 
> 
>  Thanks, that makes a lot of sense... but I still can't get 
> it to work.
> 
>   I need to maintain the original code base which defines NAME as the
> subtype NAME_TYPE and NAME_TYPE as a string of (1..40)...  
> could it have
> something to do with the use of subtypes?   To simplify 
> things for testing
> purposes I removed all that and now have a simple bounded 
> string called
> holder which I'm trying to get the value from the entry. I'm 
> still getting a
> constraint error raised on the 'get_chars' line.  I know I 
> know, probably a
> simple Ada problem...  Anybody?
> 
>       -George Clark
> 
> --------------------
>   holder : string(1..40);
> 
>    procedure On_Create_Database_Accept_Button_Clicked
>      (Object : access Gtk_Button_Record'Class)
>    is
>    begin
>      
>       holder := 
> get_chars(Create_Database_D.New_Database_Entry)(1..40);
>    --...
>    end;
> -----------------------
> 
> -----Original Message-----
> From: Michal Nowikowski [mailto:godfryd at zamek.gda.pl]
> Sent: Wednesday, January 09, 2002 2:46 AM
> To: gtkada at lists.act-europe.fr
> Subject: Re: [gtkada] simple gtk_editable question
> 
> 
>               You "Clark, G L" <g.l.clark at lmco.com> who had written:
> 
> >  I'm getting a Constraint error when trying to read the 
> characters from
> >  an editable field into a bounded string.
> 
> > subtype NAME_TYPE is string(1..40);
> > ...
> > --(Name is of type NAME_TYPE)
> > FORM_DATA.NAME := 
> get_chars(Create_Database_Dialog.New_Database_Entry);
> 
> because get_chars(Create_Database_Dialog.New_Database_Entry) 
> can return 
> another amount of chars than 40
> 
> You could do sth like this
> 
> declare
>    name : String := 
> get_chars(Create_Database_Dialog.New_Database_Entry);
> begin
>    ...
> end;
> 
> or
> 
> FORM_DATA.NAME :=
> get_chars(Create_Database_Dialog.New_Database_Entry)(1..40);
> 
> Godfryd
> 
> -- 
> |  Michal Nowikowski <godfryd at zamek.gda.pl>
> |  wymówka admina #268:
> |  Neutrino overload on the nameserver
> 
> _______________________________________________
> gtkada mailing list
> gtkada at lists.act-europe.fr
> http://lists.act-europe.fr/mailman/listinfo/gtkada
> 
> _______________________________________________
> gtkada mailing list
> gtkada at lists.act-europe.fr
> http://lists.act-europe.fr/mailman/listinfo/gtkada
> 




More information about the gtkada mailing list