Search the web
Sign In
New User? Sign Up
jsosa · JavaScript OSA-Talk
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Show off your group to the world. Share a photo of your group with us.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Preferences via defaults   Message List  
Reply | Forward Message #507 of 529 |
So there's this cool unix-shell thingy called "defaults" that
I've just become aware of. I've thrown together the following
object-wrapper as an example of using it:

Self = MacOS.appSelf();

// AppleScript's "quoted form of..."
//
String.prototype.toQuoted = function() {
return "'" + this.replace( /'/g, "\\'" ) + "'";
}

Prefs = {
plist : "My Amazing Preference Name", // don't include ".plist"
where : "~/Library/Preferences/", // note: don't quote "~/"
write : function( key, val ) {
Self.do_shell_script( "defaults write " + this.where +
this.plist.toQuoted() + " " +
String( key ).toQuoted() + " " +
String( val ).toQuoted()
);
},
read : function( key ) {
return Self.do_shell_script( "defaults read " + this.where +
this.plist.toQuoted() + " " +
String( key ).toQuoted()
);
}
}

Prefs.write( "favorite color", "plaid" );
Prefs.read ( "favorite color" ); //=> "plaid"


Goodnight,
-- Arthur




Sat Mar 18, 2006 5:16 am

admiralnovia
Offline Offline
Send Email Send Email

Forward
Message #507 of 529 |
Expand Messages Author Sort by Date

So there's this cool unix-shell thingy called "defaults" that I've just become aware of. I've thrown together the following object-wrapper as an example of...
Arthur Knapp
admiralnovia
Offline Send Email
Mar 18, 2006
5:17 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help