• 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: get properties treating variable as literal
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: get properties treating variable as literal


  • Subject: Re: get properties treating variable as literal
  • From: Emmanuel <email@hidden>
  • Date: Thu, 5 Oct 2006 01:51:18 +0200

At 4:17 PM -0700 10/4/06, Christopher Nebel wrote:
For example, if you wanted to get all of the keys as strings, you could say something like this:

tell application "System Events"
set f to file "com.apple.dashboard.plist" of the preferences folder
set p to property list file (path of f)
get name of every property list item of p
end tell
--> {"other-gadgets", "locale", "tilde-mod", "widget-list", "layer-gadgets", "slash-mod"}


Now that you have a list of strings, you can ask for individual values by their key name, such as...

	value of property list item "locale" of p
	--> "en_US"

Slightly off-topic since it uses a third-party addition, here how it would go with XMLLib.osax:


set f to file ("" & (path to preferences folder) & "com.apple.dashboard.plist")
set p to PlistOpen f
PlistGetKeys p

  --  {"layer-gadgets", "locale", "slash-mod", "tilde-mod", "widget-list"}

PlistGet p key "locale"

  --  "en_US"

OMPBG4, XMLLib is 6+ times faster in this exercise (3.5 ms vs 24 ms.)

Emmanuel
_______________________________________________
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


  • Follow-Ups:
    • Re: get properties treating variable as literal
      • From: Philip Aker <email@hidden>
    • Re: get properties treating variable as literal
      • From: Christopher Nebel <email@hidden>
References: 
 >get properties treating variable as literal (From: Jaime Magiera <email@hidden>)
 >Re: get properties treating variable as literal (From: Christopher Nebel <email@hidden>)
 >Re: get properties treating variable as literal (From: Jaime Magiera <email@hidden>)
 >Re: get properties treating variable as literal (From: Christopher Nebel <email@hidden>)

  • Prev by Date: Re: Can't turn off screen savers in System Preferences
  • Next by Date: Re: get properties treating variable as literal
  • Previous by thread: Re: get properties treating variable as literal
  • Next by thread: Re: get properties treating variable as literal
  • Index(es):
    • Date
    • Thread