Mailing Lists: Apple Mailing Lists

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

Economically handle multiple data fields in a write to file handler



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:
1. Appending directly to the file instead of a variable with a "write starting at eof" statement 125 times?
2. Using a handler that gets called 125 times so that the full "set theData to theData & contents of text field " doesn't get written out that many times?
3. Using the "theData & contents of..." method but combining the grabbing of data within each view onto one line. Something like:
set theData to theData & (contents of ...) & (contents of ...) & (contents of ...)
4. Or is this line by line explicit method fairly quick?
5. Something more clever that is beyond me.

Thanks for any ideas on how to organize. I'm including a sample of the write to file handler I'm using.
Cheers,
Joe

--Begin script sample

on write to file theObject path name pathName of type ofType
set theData to ""

tell window of theObject
set theData to theData & contents of text field "this" & return
set theData to theData & contents of text field "that" & return
-- plus a few others
tell tab view "theTabs"
tell tab view item "firstTab"
set theData to theData & contents of text field "these" & return
set theData to theData & contents of text field "those" & return
set theData to theData & contents of text view "someMore" of scroll view "someMore" & return
-- plus a dozen more on each tab view item
end tell
--repeat with 7 more tab view items
end tell
end tell

set theFile to open for access (pathName as POSIX file) with write permission
write theData to theFile as string
close access theFile
return true
end write to file
_______________________________________________
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.


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.