• 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: How to access raw data (as seen in chevron syntax)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to access raw data (as seen in chevron syntax)


  • Subject: Re: How to access raw data (as seen in chevron syntax)
  • From: Matthew Strange <email@hidden>
  • Date: Fri, 2 Jul 2010 13:05:14 -0400

On 2/7/10 8:36 AM, "Matthew Strange" <email@hidden> wrote:

I've got a PICT resource on the clipboard and I'm trying to use
AppleScript to write that data into a file. I can see the raw data
(represented within chevrons as picture:data PICT264C...) but I can
not figure out a way to actually get at those bytes.

From: Shane Stanley
If you run "clipboard info", you'll see the type of the pic. Use that in:
set x to the clipboard as <what you found>
To write it to file, use the normal write command but fill the first 512
bytes with nothing first.

OK, that works. Thank you very much.


From: Emmanuel LEVY
Use the normal write command... but specify "as string" otherwise you'll get a zero inserted between bytes, no?


Writing the PICT resource works with or without "as string" appended. Text written as Unicode would get zeros between each byte, I suspect.


From: Tommy Bollman
Actually I need a bit on enlightenment on "write 512 bytes of nothing".
I wonder how you do that, I know you use a string :) but does nothing consist of "\0" or "0" or what.


Crude version...
  repeat 512 times
    write (ASCII character 0) to myFile
  end repeat

Little better...
   write "PICT" to myFile starting at 0
   repeat 498 times
     write (ASCII character 0) to myFile
   end repeat

In doing these experiments, I found it interesting that the 'starting at' parameter interprets both 0 & 1 as meaning "the first byte."


Sadly, none of this addresses the broader question of how to actually get at those bytes. In this case, I would like to read the dimensions of the PICT, meaning I need to be able to access specific bytes in the stream. I guess I could write the file, then turn around and read the bytes back in, but that seems horribly inefficient. It just strikes me as odd that we have the data type with no way to read or manipulate it.


But thanks for the input; you've solved my immediate problem.

Matt Strange
Autograph Systems
An Authorized Apple Reseller
www.autographsystems.com


_______________________________________________ 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
  • Prev by Date: Re: controlling volume levels
  • Next by Date: Re: How to access raw data (as seen in chevron syntax)
  • Previous by thread: Re: How to access raw data (as seen in chevron syntax)
  • Next by thread: Re: How to access raw data (as seen in chevron syntax)
  • Index(es):
    • Date
    • Thread