• 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: Problem with reading 4-byte floats from file on Intel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with reading 4-byte floats from file on Intel


  • Subject: Re: Problem with reading 4-byte floats from file on Intel
  • From: Christopher Nebel <email@hidden>
  • Date: Thu, 6 Dec 2007 14:07:41 -0800

On Dec 6, 2007, at 10:27 AM, email@hidden wrote:

I am reading a binary file, of which I know the format and some of the contents, to determine whether or not it has been stored in native or non-native endian. AppleScript reads the file as big- endian (swapping bytes, apparently) regardless of whether I run the script on PPC or Intel. I want AppleScript to read the file without byte swapping.

Not going to happen, at least not with the built-in functions. AppleScript's "read" command is designed to work with files created with AppleScript's "write" command, and that's really all there is to it. "read" and "write" historically used big-endian formatting (it was the logical thing to do at the time), so they continue to do so now.


As Mr. Reed says, low-level byte-oriented I/O is not AppleScript's thing. There are scripting additions to handle it, but you'd probably be better served by Python or Perl's pack/unpack functions.

By the way, next time you post a data-reading question like this, mention up front the fact that the file was not created by AppleScript. It's kind of important.


--Chris Nebel AppleScript Engineering

_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
References: 
 >Re: Problem with reading 4-byte floats from file on Intel (From: email@hidden)
 >Re: Problem with reading 4-byte floats from file on Intel (From: "Mark J. Reed" <email@hidden>)
 >Re: Problem with reading 4-byte floats from file on Intel (From: email@hidden)

  • Prev by Date: Folder Action script runs on file renaming
  • Next by Date: Re: Folder Action script runs on file renaming
  • Previous by thread: Re: Problem with reading 4-byte floats from file on Intel
  • Next by thread: Re: Problem with reading 4-byte floats from file on Intel
  • Index(es):
    • Date
    • Thread