comp.lang.ada
 help / color / mirror / Atom feed
* creating own Image function
@ 2004-12-29 16:51 R
  2004-12-29 17:01 ` Vinzent 'Gadget' Hoefler
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: R @ 2004-12-29 16:51 UTC (permalink / raw)


Hello.

I've written my own Image function it's sth like Java's toString.

function Image(this: rec1) return String is
tmp : String(1..26);
begin
tmp := "The value of field is:" & Integer'Image(Get(this));
return tmp;
end Image;

when I use it:

testclass.Create(object, 100); -- note 100 is 3 digits = 3 Characters
Put(testclass.Image(object));

then I can see "The value of field is: 100"
when I initiate my object with 10 - 2 digits = 2 Characters
an exception is raised:
CONSTRAINT_ERROR : testclass.adb:34 length check failed

it's because tmp: Sting has it's fixed length can it be more flexible?

When I tried with String(1..100) the same effect
users can initate their objects with 1, 11, 111, 111111 and so on.

so my question is: can I write(with Your help of course) a function
flexible
to handle all those situations?

thanks in advnce
best regards R




^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2005-01-15 23:58 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-29 16:51 creating own Image function R
2004-12-29 17:01 ` Vinzent 'Gadget' Hoefler
2004-12-29 17:04 ` Mark Lorenzen
2004-12-29 17:20   ` Luke A. Guest
2004-12-29 20:56     ` Mark Lorenzen
2004-12-30  4:04       ` Jeffrey Carter
2004-12-30  8:32         ` Vinzent 'Gadget' Hoefler
2004-12-30  4:02     ` Jeffrey Carter
2005-01-15 23:58       ` Sandro Magi
2004-12-29 17:06 ` Bobby D. Bryant
2004-12-29 17:46   ` Georg Bauhaus

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