Re: Bytes into integer
Re: Bytes into integer
- Subject: Re: Bytes into integer
- From: Steve Roy <email@hidden>
- Date: Fri, 13 Feb 2004 11:10:06 -0500
Steve Roy <email@hidden> wrote:
>
Here's the Java code that does it:
>
>
int b1 = f.readUnsignedByte();
>
int b2 = f.readUnsignedByte();
>
int b3 = f.readUnsignedByte();
>
int off = (b1 << 16) + (b2 << 8) + (b3 << 0);
>
>
I'm able to read the three bytes with this:
>
>
set b1 to read theFileRef for 1
>
set b2 to read theFileRef for 1
>
set b3 to read theFileRef for 1
>
>
But I don't know any way in vanilla AppleScript to do bitwise operation like
the
>
Java code does. Is there a clever trick to do this?
Ah, I found it.
set b1 to read theFileRef for 1
set b2 to read theFileRef for 1
set b3 to read theFileRef for 1
set off to ((ASCII number b1) * 65536) + (ASCII number b2) * 256 + (ASCII number
b3)
Steve
--
Steve Roy <email@hidden>
Personal homepage: <
http://homepage.mac.com/sroy>
Projects homepage: <
http://www.roydesign.net>
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.