• 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: names of a record's items
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: names of a record's items


  • Subject: Re: names of a record's items
  • From: Ted Wrigley <email@hidden>
  • Date: Fri, 18 Apr 2014 00:52:24 -0700

Sorry for the delay: taxes…!

I got back to playing with that ‘record’ framework and remembered all the things that annoyed me about it. At any rate, I’ve uploaded a faceless background app that incorporates the framework - which solves the immediate issue, at least - while I puddle with the framework itself to see if I can work past the irritating bits. I’ll put the source code up somewhere after I’ve fussed with it a bit more, if only as an object lesson in head-banging.

App can be downloaded here: http://www.mediafire.com/download/asv5iund85jsu6g/Sidecar.zip

The app has the following commands:

sort v : Sort a list of records.
sort keys v : Sort the keys of a record.
keys of v : Retrieve a record's keys.
values of v : Exract values from a record
subset of v : Extracts a subset of a record.
filter v : Filter a list of records.

Here’s a demo script. I’ve commented in the results. Note that the script will only compile if the app is running; that’s a function of how I implemented the scripting dictionary from the framework, and is one of the annoyances I mentioned earlier.

set b to {name:1, dd:2, id:"xxx", qq:{name:"zelda", w:"hello"}, r:{1, 2, {a:"a", b:"b"}, 3}}
set z to {{a:1, b:7, c:"hello", name:"whimpy"}, {a:5, b:2, c:"goodby", name:"grumpy"}, {a:3, b:3, c:"whatever", name:"moseley"}, {a:3, b:2, c:"goodby", name:"grumpy"}}
set c to (system info)

tell application "Sidecar"
keys of b
--> {"r", name, "dd", id, "qq"}
keys of c
--> {physical memory, host name, CPU type, system version, long user name, AppleScript version, computer name, IPv4 address, AppleScript Studio version, boot volume, user ID, user locale, home directory, short user name, primary Ethernet address, CPU speed}
subset of b for keys {name, "dd"}
--> {name:1, dd:2}
values of b for keys {"dd", name, "qq", "r"}
--> {2, 1, {name:"zelda", w:"hello"}, {1, 2, {a:"a", b:"b"}, 3}}
sort keys of b
--> {dd:2, qq:{name:"zelda", w:"hello"}, r:{1, 2, {a:"a", b:"b"}, 3}, id:"xxx", name:1}
sort z using criteria {{key:"a", direction:down}, {key:"b", direction:up}}
--> {{name:"grumpy", b:2, c:"goodby", a:5}, {name:"grumpy", b:2, c:"goodby", a:3}, {name:"moseley", b:3, c:"whatever", a:3}, {name:"whimpy", b:7, c:"hello", a:1}}
filter z using predicate "a == 3"
--> {{name:"moseley", b:3, c:"whatever", a:3}, {name:"grumpy", b:2, c:"goodby", a:3}}
end tell
 _______________________________________________
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

  • Prev by Date: Re: AppleScript Application icons in Script Menu folders
  • Next by Date: Re: AppleScript Application icons in Script Menu folders
  • Previous by thread: Re: names of a record's items
  • Next by thread: Recent Items
  • Index(es):
    • Date
    • Thread