[Gambas-user] someshort="xy" returns "Wanted short, got string instead"

Benoît Minisini gambas at ...1...
Thu Sep 16 23:53:57 CEST 2010


> > 
> > Hi Benoît. Maybe there's a better way for me to have come to this point,
> > but here's what's happening:
> > 
> > A server app retrieves sets of data from five binary files and stores
> > them consecutively in a string. The first set is a 48x48 grid of shorts
> > for a total of 4608 bytes (48x48x1x2). The last four sets are 48x48
> > grids of bytes for a total of 9216 bytes (48x48x4x1). So in total we
> > have 13824 bytes (2304 shorts and 9216 bytes), converted to one large
> > string something like this:
> > 
> > DIM data AS String
> > DIM chunk AS String
> > 
> > READ #somefileofshorts, chunk, 2
> > data = data & chunk
> > 
> > READ #somefileofbytes, chunk, 1
> > data = data & chunk
> > 
> > Normally I might read the shorts into an array of shorts, but in this
> > case the final string is sent to a client app as a UDP packet. I also
> > need to send all the data as a single packet rather than several. The
> > client app receives the packet and parses it, assigning the floats and
> > bytes of the payload to five 48x48 element arrays like this:
> > 
> > DIM somearray AS Short[48, 48]
> > 
> > somearray[x, y] =  Mid$(payload, position, 2)
> > 
> > It needs to make that string to short conversion 2304 times (48x48) in as
> > little time as possible.
> > 
> > I can only think of two solutions here. One is to find a way to convert a
> > two-character string to a short as quickly as possible (the subject of
> > the post), and the other is to change the way I'm collecting the data to
> > be sent as a UDP packet so that it can be read more "normally" by the
> > client. The UDP_Read procedure is generic however, and has no way of
> > knowing what kind of data is contained within the packet, so that may be
> > difficult at best.
> > 
> > -----
> > Kevin Fishburne, Eight Virtues
> > www:  http://sales.eightvirtues.com http://sales.eightvirtues.com
> > e-mail:  mailto:sales at ...1887... sales at ...1887...
> > phone: (770) 853-6271

I have neve seen that mail, Kevin. Did it go to the mailing-list?

If I resume, you want to send the contents of an array of short on a UDP 
socket, and get it back on the other end of the socket?

-- 
Benoît Minisini




More information about the User mailing list