• 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
Iterating over items in a record, possible?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Iterating over items in a record, possible?


  • Subject: Iterating over items in a record, possible?
  • From: Ken Tozier <email@hidden>
  • Date: Fri, 9 Jan 2009 05:08:28 -0500

Hi

I'm writing a general purpose script to convert a complex nested record into an Apple "plist" and can't figure out how to iterate over items in a record if I don't know any of the record keys beforehand. For example, given the following record, I'd like to iterate the items and get the keywords and the values something like the following pseudo-code

set aRecord to {height: 100, width: 100, originX: 10, originY: 10}

set xml to "<dict>" & return
repeat with anItem in aRecord
	set itemKey to keyword of anItem
	set itemValue to value of anItem
	set xml to xml & tab & "<key>" & itemKey & "</key>" & return
	set xml to xml & tab & "<string>" & itemValue & "</string >" & return
end
set xml to xml & "</dict>"

Keep in mind, I have no control over the keywords and I actually don't know what they are. They are whatever the target application returns for a query.

Thanks for any help


_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: Iterating over items in a record, possible?
      • From: Emmanuel Levy <email@hidden>
  • Prev by Date: Re: Script to save webloc
  • Next by Date: Re: count pages in PDF on OS 10.4
  • Previous by thread: Re: Tell Blocks Considered Harmful (was Re: open for access)
  • Next by thread: Re: Iterating over items in a record, possible?
  • Index(es):
    • Date
    • Thread