creating own Image function

From: R (ruthless_at_poczta.onet.pl)
Date: 12/29/04


Date: 29 Dec 2004 08:51:43 -0800

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



Relevant Pages

  • Re: creating own Image function
    ... > function Image(this: rec1) return String is ... not take your knowledge of other languages into "Ada world". ... > it's because tmp: Sting has it's fixed length can it be more flexible? ...
    (comp.lang.ada)
  • Re: creating own Image function
    ... > I've written my own Image function it's sth like Java's toString. ... > function Imagereturn String is ... > it's because tmp: Sting has it's fixed length can it be more flexible? ... I think you can declare tmp as - ...
    (comp.lang.ada)
  • Re: creating own Image function
    ... > function Image(this: rec1) return String is ... > return tmp; ... Vinzent. ...
    (comp.lang.ada)
  • Re: unconcatenated
    ... Public Function fGetFirstChars_Nums_w(pString As Variant) As String ... Dim tmp As String ... Dim strRemStr As String ... For cntr = 1 To bytRemLen ...
    (microsoft.public.access.modulesdaovba)
  • Re: unconcatenated
    ... Public Function fGetFirstChars_Nums_w(pString As Variant) As String ... Dim tmp As String ... Dim strRemStr As String ... For cntr = 1 To bytRemLen ...
    (microsoft.public.access.modulesdaovba)