• 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
Re: Bytes into integer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Re: delay 1 millisecond in Panther
  • Next by Date: Select focus for GUI script
  • Previous by thread: Re: Bytes into integer
  • Next by thread: Re: Bytes into integer
  • Index(es):
    • Date
    • Thread