• 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: A question on technique
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A question on technique


  • Subject: Re: A question on technique
  • From: Shane Stanley <email@hidden>
  • Date: Mon, 16 Mar 2015 09:20:09 +1100

On 16 Mar 2015, at 8:33 am, Gil Dawson <email@hidden> wrote:

I think of maybe using records, but I don't see quite how.

If you're running Yosemite, you can use their Cocoa cousins, dictionaries. You'd make a dictionary using the codes as keys and the mnemonics as the objects. Then you just ask for the object for a particular key:

use framework "Foundation"

property Codes : {"9420", "94ae", "94d0", "942f", "942C", "9470"}
property Mnemonics : {"RCL", "ENM", "ReW", "EOC", "EDM", "RfW"}
property codesAndMnemonics : missing value -- will hold dictionary

-- create dictionary early in your code
set codesAndMnemonics to current application's NSDictionary's dictionaryWithObjects:Mnemonics forKeys:Codes

MnemonicOf("9470") --> "RfW"

on MnemonicOf(aCode)
set returnResult to codesAndMnemonics's objectForKey:aCode
if returnResult = missing value then
-- whatever
return false
else
return returnResult as text
end if
end MnemonicOf

-- 
Shane Stanley <email@hidden>
<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

References: 
 >A question on technique (From: Gil Dawson <email@hidden>)

  • Prev by Date: A question on technique
  • Next by Date: Re: A question on technique
  • Previous by thread: A question on technique
  • Next by thread: Re: A question on technique
  • Index(es):
    • Date
    • Thread