Re: Delphi.NET



Daniel Hobson wrote:
I was wondering if anybody is out there who uses Delphi.NET. We seem to be having a few problems in knowning
about the new requirements of DotNET. The main one that has us really stumped is how do you
convert from one data type to another different data type?

For example:-

Type
TTestRec = record
t1: array [1..32] of char;
t2: array [1..28] of char;
end;

MyBuffer : TidBytes;
MyActType : TTestRec;

I read in the information via TCP/IP into MyBuffer (Have no choice in the matter)

The question is now .. how can I say that MyBuffer is type TTestRec ????

You don't. That would by lying. You've clearly declared MyBuffer as a completely different type.

What you're trying to do is get the contents of the MyBuffer array into the MyActType record. That task is really trivial, so I suppose the unwritten part of your question is that you want to get the array contents into the record without actually having to write a loop yourself.

For that, you can use the System.Runtime.InteropServices.Marshal class. It has a Copy method overloaded to take lots of different parameter types.

--
Rob
.



Relevant Pages

  • Re: Delphi.NET
    ... convert from one data type to another different data type? ... MyActType: TTestRec; ... I read in the information via TCP/IP into MyBuffer (Have no choice in the ... TidBytes is an array of bytes. ...
    (comp.lang.pascal.delphi.misc)
  • Delphi.NET
    ... about the new requirements of DotNET. ... convert from one data type to another different data type? ... MyActType: TTestRec; ... I read in the information via TCP/IP into MyBuffer ...
    (comp.lang.pascal.delphi.misc)
  • Re: Delphi.NET
    ... convert from one data type to another different data type? ... MyActType: TTestRec; ... I read in the information via TCP/IP into MyBuffer (Have no choice in the ... Since you cannot use a fixed length array in the TCP/IP routine, ...
    (comp.lang.pascal.delphi.misc)
  • Re: Delphi.NET
    ... MyActType: TTestRec; ... I read in the information via TCP/IP into MyBuffer ... What you're trying to do is get the contents of the MyBuffer array into the MyActType record. ...
    (comp.lang.pascal.delphi.misc)
  • Delphi.NET
    ... about the new requirements of DotNET. ... convert from one data type to another different data type? ... MyActType: TTestRec; ... I read in the information via TCP/IP into MyBuffer (Have no choice in the ...
    (alt.comp.lang.borland-delphi)