Here's an example of using shell to store and retrieve Preferences
Here's an example of using shell to store and retrieve Preferences
- Subject: Here's an example of using shell to store and retrieve Preferences
- From: Jim Burton <email@hidden>
- Date: Wed, 28 Aug 2002 23:17:52 -0600
-- Example of setting and retrieving values stored in OSX Preferences
using Shell
-- by Jim Burton -- placed in public domain
--
-- Checking for keypress requires Jon's CommandsX installed in your
/Library/ScriptingAdditons folder.
-- Jon's Commands is available at
http://www.seanet.com/~jonpugh/
--
on run
-- first we'll see if our value is currently stored in Preferences
try
set emailad to do shell script "defaults read com.spamcopsend.mac
\"email\""
-- if not, then an error is thrown. Catch it...
on error errmsg number errnum
-- then call the preference-setting routine
setad()
end try
try
-- let's see if the option key has been pressed. If it has, then the
user wants to enter a new preference
-- (keys pressed) comes from Jon's CommandsX, a required Scripting
Addition
if (keys pressed) contains {"Option"} then
setad()
end if
end try
set emailad to getad()
return emailad
end run
on setad()
-- ask for the information we need
set theResult to display dialog "What is your SPAMCOP email reporting
address?" default answer ""
set theAddress to text returned of theResult
-- then write the information to 'defaults'
do shell script "defaults write com.spamcopsend.mac \"email\" '" &
theAddress & "'"
end setad
on getad()
set emailad to do shell script "defaults read com.spamcopsend.mac
\"email\""
return emailad
end getad
_______________________________________________
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.