• 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: getting a list of labels from a record?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getting a list of labels from a record?


  • Subject: Re: getting a list of labels from a record?
  • From: Shane Stanley <email@hidden>
  • Date: Tue, 28 May 2013 11:49:45 +1000

On 28/05/2013, at 11:04 AM, Alex Hall <email@hidden> wrote:

Bottom line: can I retrieve just the labels of a record as a list?

There are various hacks, usually involving trying to coerce the record to text, extracting the error string, and parsing it with text item delimiters.

If you're not averse to some outside help, there's always:

tell application "ASObjC Runner" to set theLables to all labels of {theFirst:1, theSecond:2, theThird:3}
--> {"theFirst", "theSecond", "theThird"}

But I'm not sure why you need to get involved in records in the first place. Rather than sorting your list of keywords, you could make a list of keyword-replacement pairs, and sort them by their first item. So you would sort {{"$network", network}, {"$signalStrength", signalStrength}}, sorting on the first item of each sublist.

Again, with some outside help:

set network to "Linksys"
set signalStrength to "-69"
tell application "ASObjC Runner"
set newList to modify list {{"$networklong", "$network", "$signalStrength"}, {network, network, signalStrength}} with cols to rows
set newList to rearrange list of lists newList by indexes {1}
end tell
--> {{"$network", "Linksys"}, {"$networklong", "Linksys"}, {"$signalStrength", "-69"}}

But you should be able to modify your existing sort routine suitably anyway.

However...

Wouldn't it be a lot easier to just modify your use of str_replace so that the search strings had, say, your $ delimiter at each end, as in $network$, or perhaps something like <network>? It just strikes me as a good place for application of the KISS principle.

-- 
Shane Stanley <email@hidden>
'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>

 _______________________________________________
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: getting a list of labels from a record?
      • From: Alex Hall <email@hidden>
References: 
 >getting a list of labels from a record? (From: Alex Hall <email@hidden>)

  • Prev by Date: getting a list of labels from a record?
  • Next by Date: Re: The latest AS date and AS Editor bugs
  • Previous by thread: getting a list of labels from a record?
  • Next by thread: Re: getting a list of labels from a record?
  • Index(es):
    • Date
    • Thread