• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Bytes into integer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Re: FileMaker question
  • Next by Date: Re: Finding out is an Application is running
  • Previous by thread: Re: FileMaker question
  • Next by thread: Re: Bytes into integer
  • Index(es):
    • Date
    • Thread