[Gambas-user] Reading hex from a string socket read
adam krell
akrell at ...43...
Thu Feb 19 23:00:29 CET 2004
Ah, yes, that seems a little better for my int values.
Some of my data is ints and others are hex codes
and still others are strings. I was using a variety of
functions to decode the data. I also had to implement
a manual "buffer counter". As was mentioned,
pack/unpack type command or sprintf() would be a fast
way to do this kind of stuff.
I was mainly concerned with increasing speed. I
found out that some debug code I had was slowing it
down. When I removed that the speed was fine.
Thanks,
Adam
--- Rob <sourceforge-raindog2 at ...94...> wrote:
> On Thursday 19 February 2004 09:01, adam krell
> wrote:
> > TwoByteCode = Val(Str$(Asc(Mid$(Buffer,1,1))) &
> > Str$(Asc(Mid$(Buffer,2,1))))
> > Is there a more efficient way to do this?
>
> I'd think the following would work to build an int
> value from two
> bytes of binary data, high byte first:
>
> TwoByteCode = asc(mid$(buffer,1,1)) * 256 +
> asc(mid$(buffer,2,1))
>
> But that's so different from what you're doing that
> I need to see
> an example of the input values you're looking at,
> and the
> expected value of TwoByteCode when you're done.
>
> I know eventually there'll need to be some kind of
> "pack/unpack"
> function set for Gambas because you need to go from
> binary to
> hex to integer (or array) a lot when dealing with
> legacy systems
> and ISO protocols. I don't think my C's up to that
> right now,
> though (maybe I can figure out how it works in perl
> and copy
> their code somehow.... ugh)
>
> Rob
>
>
>
>
-------------------------------------------------------
> SF.Net is sponsored by: Speed Start Your Linux Apps
> Now.
> Build and deploy apps & Web services for Linux with
> a free DVD software kit from IBM. Click Now!
>
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
>
https://lists.sourceforge.net/lists/listinfo/gambas-user
__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools
More information about the User
mailing list