In message <
528414d...@iank.org.uk>
I'm ssuming the existing program is a Wimp program. If not, I'm not
sure you can do it.
It will make a big difference in your code whether you can block
waiting for the message, or whether you need the computer to respond
to user input while waiting for data. The latter is a bit more
complicated to code. Assuming the latter...
First you need to know whether the data is being sent using TCP or UDP
packets. There's a fundamental difference between the way these two
work.
UDP (unreliable datagram protocol) doesn't guarantee to deliver the
data, but if is is delivered then the message arrives in a single
piece.
TCP does guarantee to deliver the data (which is why it is the more
common form of transport) but the data may be fragmented, arriving in
several pieces.
For TCP generally you will want a handler called from wimp_pollidle
which checks whether there is anything received. If there is, copy it
into a buffer (NOT a BASIC string, because it may be too long), adding
to what may already be in the buffer and set a flag for the main
program to know something has arrived.
For TCP you will need a way to know whether the buffer contains a
complete message, and where the start and end are. If you have control
over the sender, it's a case of wrapping the message in markers, for
example a character or string that the message itself is guaranteed
never to contain. If not, you need to know exactly what is being sent,
so you can search the buffer for it.
Once your complete message is in the buffer, you can process it. That
initial processing will also need to be in a Wimp_Pollidle call, as
the programme will have to wait for data.
I would strongly advise getting and using !Reporter, if you don't
already. Debugging this stuff can be tricky.
--
Alan Adams, from Northamptonshire
al...@adamshome.org.uk
http://www.nckc.org.uk/