[gtkada] gtk.text to string
Siddhartha Ray
SiddharthaR at TucsonEmbedded.com
Thu Aug 16 16:19:58 CEST 2001
Hi,
text : string:=""; is a constrained string. You cannot assign anything
to it that is more than the length of "". That is why you get the
constraint error.
Therefore if you kind of know what the size of the string you
are expecting from Get_Text, say 80 characters then:
text : string (1 .. 80) := (others => ascii.nul);
...
text := gtk.text.get_text (texto);
put (text);
if you do not know what the size of string is then the easiest/dirtiest way
is
type string_ptr is access all string;
text : string_ptr := null;
...
text := new String'(gtk.text.get_text(texto));
put(text.all);
should do it.
Or you can look into the Ada.Strings.Unbounded package and do
something like
text : ada.strings.unbounded.unbounded_string :=
ada.strings.unbounded.null_unbounded_string;
...
text :=
ada.strings.unbounded.to_unbounded_string(gtk.text.get_text(texto));
put(ada.strings.unbounded.to_string(text));
These techniques should do it.
-Sid
-----Original Message-----
From: luix [mailto:luix at tropicalstorm.com]
Sent: Thursday, August 16, 2001 3:37 AM
To: gtkada at gtkada.eu.org
Subject: [gtkada] gtk.text to string
I'm trying to pass gtk.text to a text file, the only way I've founded is
passing it to string before putting in the text file, so I tried to use the
get_text function (in gtk-text) and it compiles but I get a constraint
error when running, this is my procedure:
procedure convertir (b: access gtk.button.gtk_button_record'class) is
text: string:="";
begin
cadena:=gtk.text.get_text(texto);
put(text); --I did this only to know if it runs
end convertir;
I don't know what am I doing wrong, as the delcaration of the function is:
function Get_Text (Text : access Gtk_Text_Record) return String is
and I can't find any info about this in the gtkada_rm.
please help!
thanks
Luis.
_____________________________________________
Free email with personality! Over 200 domains!
http://www.MyOwnEmail.com
_______________________________________________
gtkada mailing list
gtkada at lists.act-europe.fr
http://lists.act-europe.fr/mailman/listinfo/gtkada
More information about the gtkada
mailing list