Bytes into integer
Bytes into integer
- Subject: Bytes into integer
- From: Steve Roy <email@hidden>
- Date: Fri, 13 Feb 2004 08:31:59 -0500
Hi,
I'm trying to extract a value out of a binary file with AppleScript. I have to
read three bytes and turn them into an integer.
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?
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.