🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.delphi.language.delphi.dotnet
3 messages
3 total messages Started by Gerald geraldmcnicholl yahoo.com Thu, 19 Jun 2008 21:47
No overloaded version of 'Write' ?? (Delphi2007 for .NET)
#47
Author: Gerald geraldmcnicholl yahoo.com
Date: Thu, 19 Jun 2008 21:47
38 lines
1781 bytes
Hi,

I'm trying to save a simpile record to a TStream, my code is as
follows:

Type
 tsimple = Record
   a : Integer;
   s : String[20];
  end;
.........
Var
   astream : TMemorystream;
   asimple  :  tsimple;
Begin
   astream := TMemorystream.create;
   asimple.a := 4;
   asimple.s := 'Hello World!';
   astream.Write(asimple, sizeof(asimple));
   astream.free;
End;


It errors on the  astream.Write(asimple, sizeof(asimple)); line saying
"There is no overloaded version of 'Write' that can be called with
these arguments. Why??

I've heard that Write could be expecting a poiinter, but if I change
the line to astream.Write( @asimple, sizeof(asimple) ); I still get
the same error message.

This works fine in Delphi2007 for Win32, but I cannot work out why
it's not working in .NET.

Can someone please let me know where I am going wrong?

Thanks,
Gerald.
Re: No overloaded version of 'Write' ?? (Delphi2007 for .NET)
#48
Author: Rudy Velthuis [TeamB]
Date: Thu, 19 Jun 2008 22:11
37 lines
2842 bytes
Gerald wrote:

> Hi,
> 
> I'm trying to save a simpile record to a TStream, my code is as
> follows:
> 
> Type
>  tsimple = Record
>    a : Integer;
>    s : String[20];
>   end;
> .........
> Var
>    astream : TMemorystream;
>    asimple  :  tsimple;
> Begin
>    astream := TMemorystream.create;
>    asimple.a := 4;
>    asimple.s := 'Hello World!';
>    astream.Write(asimple, sizeof(asimple));
>    astream.free;
> End;
> 
> 
> It errors on the  astream.Write(asimple, sizeof(asimple)); line saying
> "There is no overloaded version of 'Write' that can be called with
> these arguments. Why??

Because TStream.Write has no overloaded version for the TSimple type,
in .NET. Your code should work in Win32, but not in .NET. In .NET, you
should probably write the Integer and then the short string.
-- 
Rudy Velthuis [TeamB]        http://www.teamb.com

"In this war � as in others � I am less interested in honoring
 the dead than in preventing the dead." -- Butler Shaffer
Re: No overloaded version of 'Write' ?? (Delphi2007 for .NET)
#49
Author: Gerald geraldmcnicholl yahoo.com
Date: Thu, 19 Jun 2008 23:09
15 lines
1486 bytes
On Fri, 20 Jun 2008 00:11:40 +0200, "Rudy Velthuis [TeamB]"
<newsgroups@rvelthuis.de> wrote:


>Because TStream.Write has no overloaded version for the TSimple type,
>in .NET. Your code should work in Win32, but not in .NET. In .NET, you
>should probably write the Integer and then the short string.

Thanks Rudy,

That's of great help. I can see now where I was going wrong. Thanks
for the quick reply!!

Cheers ....
Gerald.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads