Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Economically handle multiple data fields in a write to file handler



On Wednesday, December 3, 2003, at 08:58 PM, Joseph Weaks wrote:

> I'm finally getting a document based ASS app working (my first one!).
> I'm using the low-level handler to write to file in XCode. The write
> to file handler currently grabs the contents of about 125 text fields
> (well a few are text views and even a couple popups) each with its own
> "set theData to theData & newStuff" line and then writes "theData" to
> a file.
>

> So, now it's time to fine tune it to get the quickest method. Which
> is the most economical in terms of speed:

Personally, I use something like this:
on write to file theObject path name pathName of type ofType
set theData to {}

tell window of theObject
set end of theData to (contents of text field "this" & return)
set end of theData to (contents of text field "that" & return)

...
end tell

set theFile to open for access (pathName as POSIX file) with write
permission
write (theData as string) to theFile
close access theFile
end write to file

A long time ago some Mighty Smart Folks on the macscript list found out
that appending to a list was much faster than the implicit copying,
appending, and then destroying the old object that happens when you"set
a to a & b".

I hope this helps,
_Ryan Wilcox
_______________________________________________
applescript-studio mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-studio
Do not post admin requests to the list. They will be ignored.

References: 
 >Economically handle multiple data fields in a write to file handler (From: Joseph Weaks <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.