• 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: Christopher Nebel <email@hidden>
  • Date: Wed, 4 Oct 2006 16:17:24 -0700

On Oct 4, 2006, at 12:22 PM, Jaime Magiera wrote:

On Oct 4, 2006, at 2:11 PM, Christopher Nebel wrote:

On Oct 4, 2006, at 9:45 AM, Jaime Magiera wrote:

You omitted the context about exactly what currentPreferencesArray and uniqueKey are, but I'm guessing from your question that they're a record and a string, respectively. Record keys are not strings and cannot be put into variables. Strings are not record keys, and cannot be used to access record values. [1] Assuming my guess was correct, the solution to your problem will vary depending on where currentPreferencesArray is coming from and how much control you have over it.

- currentPreferencesArray is an array of preferences from PLIST Suite (in other words, an array of arrays of records)


{{|displayName|:"black", |hostName|:"not applicable", protocol:"Local Folder", |baseURL|:"http://fakeurl.com";, | remotePath|:"not applicable", |userName|:"not applicable", | uniqueServerID|:99.763908842249, |memberName|:"not applicable"}, {| displayName|:"yellow", |hostName|:"not applicable", protocol:"Local Folder", |baseURL|:"http://anotherfakeurl.com";, |remotePath|:"not applicable", |userName|:"not applicable", |uniqueServerID|: 109.45973, |memberName|:"not applicable"} }

-- I'm trying to create a general method that will, given an array of plist preferences and a uniqueKey, determine if any new preference objects conflict with old ones. In the case above, uniqueServerID would be the unique key. I previously hard coded the method for the objects above. However, I'd like the flexibility of a general method.

Does that help paint the picture? Thanks everyone.

Do you mean System Events' Property List Suite? If so, then you asked it for the wrong thing. People tend to ask for "value of ...", get a record, and then forget that there's an object model below that, too. 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"


--Chris Nebel AppleScript Engineering

_______________________________________________
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: Jaime Magiera <email@hidden>
    • Re: get properties treating variable as literal
      • From: Emmanuel <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>)

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