• 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: Writing Binary Files, Data Code Limitations, and Unicode Tables (not necessarily in that order)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Writing Binary Files, Data Code Limitations, and Unicode Tables (not necessarily in that order)


  • Subject: Re: Writing Binary Files, Data Code Limitations, and Unicode Tables (not necessarily in that order)
  • From: BJ Terry <email@hidden>
  • Date: Fri, 21 Nov 2003 11:22:37 -0800

On Nov 20, 2003, at 12:55 PM, Michael Terry wrote:
> Hello,
>
> Has anyone ever noticed that you can't compile data codes with 'run
> script' if the number of characters in the string is too big? And too
> big isn't even all that big. I can't compile
>
> set d to "+data data0000;"
> run script d
>
> if I add enough zeros to make 'd' longer than 266 characters. "Way too
> long, dude." I've wondered if that's one of Jon Pugh's...
>
> Anyway, the reason I ask is because I was trying to write some data to
> file, and it would go a lot faster if I didn't have to keep stopping
> every so often to compile tiny little chunks of data. Unfortunately, I
> can't see any way to write binary data to a file other than assembling
> it via 'run script' first. Are there other options? If you wanted to
> write out a list of unicode characters, how would you do it?

Here's my version:
--------------------------------------------------------
property hexChars : "0123456789ABCDEF"
property bom : run script "<<data dataFEFF>>"

set startTime to current date
set fileRef to file specification (((path to temporary items) as
Unicode text) & "Unicode Table.txt")
open for access fileRef with write permission
write bom to fileRef

set codepoints to {}
set compilableBlock to ""
repeat with i from 1 to 16
repeat with j from 1 to 16
repeat with k from 1 to 16
repeat with l from 1 to 16
tell hexChars
set compilableBlock to compilableBlock & its item i & its item j & its
item k & its item l
end tell
end repeat
write (run script "<<data data" & compilableBlock & ">>") to fileRef
set compilableBlock to ""
end repeat
end repeat
end repeat

close access fileRef
-- `60 sec
-------------------------------------------------------------------

By my testing it's a tad bit faster than yours. You can speed it up by
writing the data directly to a file rather than saving it in a list
first.
Newbie note: the >> and << must be replaced by bona fide French
guillemots. Shift-option-l and option-l on my computer.

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.

References: 
 >Writing Binary Files, Data Code Limitations, and Unicode Tables (not necessarily in that order) (From: Michael Terry <email@hidden>)

  • Prev by Date: Re: Script Editor self starting
  • Next by Date: Re: iCal Todo notes
  • Previous by thread: Re: Writing Binary Files, Data Code Limitations, and Unicode Tables (not necessarily in that order)
  • Next by thread: "save as" question
  • Index(es):
    • Date
    • Thread