• 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: Creating preferences for an applescript application
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating preferences for an applescript application


  • Subject: Re: Creating preferences for an applescript application
  • From: Skinner Paul <email@hidden>
  • Date: Fri, 26 Nov 2004 18:46:00 -0500

You might want to look into xls and do shell script "defaults read" and do shell script "defaults write", but I've a set of a vanilla handlers you can play with. If you want others to be able to edit the preffile then you'd want to write it as text and parse it when you read it. Otherwise, they'll have to edit something like..."recousrflistTEXTcTEXTcTEXTalongTEXTinitializationdateldt ΩÕ*TEXTmodificationdateldt ΩÕ*".

tell prefer
set prefFileName to "
testPref"


if not prefFileName) then
prefFileName)
else
prefFileName)
-->true
prefFileName)
-->alias "batzmaru:Users:paul:Library:Preferences:testPref"
end if
prefFileName)
-->{initializationDate:date "Friday, November 26, 2004 6:26:52 PM", modificationDate:date "Friday, November 26, 2004 6:26:52 PM"}
prefFileName, {c:"
c", a:8})
-->true
prefFileName)
-->{c:"c", a:8, initializationDate:date "Friday, November 26, 2004 6:26:10 PM", modificationDate:date "Friday, November 26, 2004 6:26:10 PM"}
prefFileName, {c:"
sea", a:888})
-->true
prefFileName)
-->{c:"sea", a:888, initializationDate:date "Friday, November 26, 2004 6:34:37 PM", modificationDate:date "Friday, November 26, 2004 6:34:37 PM"}
prefFileName)
-->true
prefFileName)
-->{initializationDate:date "Friday, November 26, 2004 6:27:44 PM", modificationDate:date "Friday, November 26, 2004 6:27:46 PM"}
end tell



script prefer
on prefFileName)
set preFilePath to "" & ((path to preferences folder from user domain as string) & prefFileName)
try
set preFilePath to preFilePath as alias
return true
on error
return false
end try
end existsPreference


on prefFileName)
set preFilePath to "" & ((path to preferences folder from user domain as string) & prefFileName)
try
set preFilePath to preFilePath as alias
tell application "
Finder"
delete preFilePath
return true
end tell
on error
return false
end try
end removePreference


on prefFileName)
set preFilePath to "" & ((path to preferences folder from user domain as string) & prefFileName)
try
set preFilePath to preFilePath as alias
return false
on error
try
close access preFilePath
end try
try
set prefRef to open for access preFilePath with write permission
set eof of prefRef to
0
set currentTime to current date
write {currentTime, currentTime} to prefRef as record
close access prefRef
return preFilePath as alias
on error e
try
close access prefRef
return e
end try
end try
end try
end makePrefFile




on prefFileName)
set AppleScript's text item delimiters to "
:"
try
set prefs to read file ("" & (path to preferences folder from user domain as string) & prefFileName) as record
on error
return false
end try
return prefs
end readPreferences


on prefFileName)
set preFilePath to "" & ((path to preferences folder from user domain as string) & prefFileName)
try
set preFilePath to preFilePath as alias
set creationdate to initializationDate of my prefFileName)
try
close access preFilePath
end try
try
set prefRef to open for access preFilePath with write permission
set eof of prefRef to
0
write {creationdate, current date} to prefRef as record
close access prefRef
return true
on error e
try
close access prefRef
return e
end try
end try
on error
return false
end try
end clearPreferences


on prefFileName, preferenceRecord)
try
set prefFile to (("" & (path to preferences folder from user domain as string) & prefFileName) as alias) as text
on error
return false
end try
if preferenceRecord is {} then
set prefs to {current date, current date}
else
set prefs to read file prefFile as record
set prefs to preferenceRecord & prefs & {current date}
end if
try
try
close access file prefFile
end try
set prefRef to open for access file prefFile with write permission
--set eof of prefRef to 0
write prefs to prefRef as record
close access prefRef
--set prefs to read file prefFile as record
return true
on error
try
close access prefRef
return false
end try
end try
end writePrefs
end script


On Nov 22, 2004, at 11:42 AM, Bjorn Sodergren wrote:

I wrote a couple of small applescript applications to assist us in the
prepress area. However, i would like to make it easy for others to
change some of the properties i use in the script (server, user/pass,
directories)

Does anyone know of some good docs or examples that will help me
support this feature?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Creating preferences for an applescript application (From: Bjorn Sodergren <email@hidden>)

  • Prev by Date: Re: Save EPS page from Acrobat
  • Next by Date: Re: Network / AS query
  • Previous by thread: Re: Creating preferences for an applescript application
  • Next by thread: include a file
  • Index(es):
    • Date
    • Thread