<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
The second part of the email is basically, would this work:<br>
<br>
If I have an automation object with a IPolygon interface and a method
on that interface called AddPoints such as :<br>
<br>
IPolygonInterface = interface(IDispatch)<br>
&nbsp;&nbsp;&nbsp; AddPoints(PointsArray : OleVariant);<br>
end;<br>
<br>
where PointsArray is a variant array which contains Single values (X, Y
values on a map) that should work shouldn't it (as long as client knows
they are Singles?<br>
<br>
Wouldn't this be achieving the same thing as sending the points to a
stream, converting that stream to a variant array of bytes, and sending
the array as an OleVariant?<br>
<br>
Phil.<br>
<br>
Conor Boyd wrote:
<blockquote
 cite="mid8285CB7241FCFC4BB721A6F953F9B35E04968763@nzc-ap-xch-01.ap.trimblecorp.net"
 type="cite">
  <pre wrap="">In theory it would work with a VB client etc, but on the understanding
that the VB code that does the unstreaming would need to know intimately
the structure of the byte arrays being passed.

I suppose we're lucky in that our client and server are both Delphi, so
we just compile the streaming classes into both projects and it just
works.

The other thing to point out about streaming using byte arrays is that
it's not version-safe (e.g. you change the format of your internal byte
arrays being streamed and every client will need to know about it).
We're safe because our server and clients are always in sync, but it's
something to be aware of.

Not sure I understand the second part of your email, but that may just
be me being stupid.

C.

-----Original Message-----
From: <a class="moz-txt-link-abbreviated" href="mailto:delphi-bounces@ns3.123.co.nz">delphi-bounces@ns3.123.co.nz</a> [<a class="moz-txt-link-freetext" href="mailto:delphi-bounces@ns3.123.co.nz">mailto:delphi-bounces@ns3.123.co.nz</a>]
On Behalf Of Phil Middlemiss

I didn't realise variant arrays were automation compatible - the help
doesn't indicate this. Would this work for a VB or C++ client app?

I'm wondering if I can shortcut the whole thing though - I have an
automation interface that represents, say, a polygon. Since the client
code still has to formulate a variant array (to pass to the
TStreamable), why not just pass the variant array to the polygon
interface?

eg, IMyPolygon.AddPoints(Points : OleVariant);

Cheers,
Phil.

Conor Boyd wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">Look into creating some sort of streaming framework. 

E.g.

Have a base TStreamable class.

Then declare "transport" type classes for each item of data you want 
to pass between client and server.

Have your base TStreamable class know how to take a stream and turn it
    </pre>
  </blockquote>
  <pre wrap=""><!---->
  </pre>
  <blockquote type="cite">
    <pre wrap="">into an OleVariant.

Have each of your transport classes implement a ReadFromStream and 
SaveToStream method which writes the internal values of the object to 
the stream.

E.g.

Tstreamable = class
Public
  procedure ReadFromStream(Stream: Tstream); virtual;
  procedure WriteToStream(Stream: Tstream); virtual;

  function ToVariant: OleVariant;
  procedure FromVariant(vrnt: OleVariant); End;

TMyInfo = class(Tstreamable)
Private
  FSomeInfo: String;
  FSomeOtherInfo: Tpoint;
Public
  procedure ReadFromStream(Stream: Tstream); override;
  procedure WriteToStream(Stream: Tstream); override;

  property SomeInfo: String read FSomeInfo write FSomeInfo;
  property SomeOtherInfo; Tpoint read FSomeOtherInfo write 
FSomeOtherInfo; End;

Your TMyInfo class knows how to read and write it's internal fields 
to/from a Tstream.

Your code that wants to send that info between client and server calls
    </pre>
  </blockquote>
  <pre wrap=""><!---->
  </pre>
  <blockquote type="cite">
    <pre wrap="">ToVariant and FromVariant on the TMyInfo class and sends the
    </pre>
  </blockquote>
  <pre wrap=""><!---->OleVariant.
  </pre>
  <blockquote type="cite">
    <pre wrap="">The ToVariant and FromVariant methods need to take a Tstream and turn 
it into a VarArray of type varByte, which is the actual OleVariant 
that gets transported.

I wrote this at some speed, so not sure if it'll make 100% sense 
straight off.  Let me know if you want more specifics or some sample 
code.

I use this type of framework for transporting classes, records, 
arrays, etc.  You can chain this type of stuff together so that 
complex objects in turn use the ReadFromStream/WriteToStream methods 
on internal fields as appropriate.

HTH,

Conor

-----Original Message-----
From: <a class="moz-txt-link-abbreviated" href="mailto:delphi-bounces@ns3.123.co.nz">delphi-bounces@ns3.123.co.nz</a> 
[<a class="moz-txt-link-freetext" href="mailto:delphi-bounces@ns3.123.co.nz">mailto:delphi-bounces@ns3.123.co.nz</a>]
On Behalf Of Phil Middlemiss

Having read the help about which data types are automation compatible,
    </pre>
  </blockquote>
  <pre wrap=""><!---->
  </pre>
  <blockquote type="cite">
    <pre wrap="">it seems there is no quick way to send a chuck of memory to an 
automation object: The only option I can see is to send the data 
integer by integer (if I'm sending TPoint then send X and Y for every
    </pre>
  </blockquote>
  <pre wrap=""><!---->point).
  </pre>
  <blockquote type="cite">
    <pre wrap="">_______________________________________________
Delphi mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</a>
<a class="moz-txt-link-freetext" href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</a>



  
    </pre>
  </blockquote>
  <pre wrap=""><!---->
_______________________________________________
Delphi mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</a>
<a class="moz-txt-link-freetext" href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</a>



  </pre>
</blockquote>
</body>
</html>