Re: A question on technique
Re: A question on technique
- Subject: Re: A question on technique
- From: Emmanuel LEVY <email@hidden>
- Date: Mon, 16 Mar 2015 00:13:41 +0100
XMLLib's plists solution:
1. build the plist:
property Codes : {"9420", "94ae", "94d0", "942f", "942C", "9470"}
property Mnemonics : {"RCL", "ENM", "ReW", "EOC", "EDM", "RfW"}
set p to plistnew
plistset p key Codes to Mnemonics
2. use the plist
set themnemonic to plistget p key acode
3. if you wish, store the plist
plistsave p in [ some file ]
then:
set p to plistopen [ that file ]
Best,
Emmanuel
On Mar 15, 2015, at 10:33 PM, Gil Dawson wrote:
> Hi--
>
> I wish to translate a sequence of codes into corresponding mnemonics.
>
> Two same-length properties encode the correspondence.
>
> property Codes : {"9420", "94ae", "94d0", "942f", "942C", "9470"}
> property Mnemonics : {"RCL", "ENM", "ReW", "EOC", "EDM", "RfW"}
>
> Eventually I expect the two lists to be much larger.
>
> The following code works well enough...
>
> on MnemonicOf(aCode)
> set Found to false
> repeat with k from 1 to the length of Codes
> if item k of Codes is equal to aCode then
> set ReturnResult to item k of Mnemonics
> set Found to true
> exit repeat
> end if
> end repeat
> if not Found...
>
> ...but is there another, perhaps faster, way to do this?
>
> I think of constructs like...
>
> if aCode is in Codes then...
>
> ...but I don't see how to index the Mnemonics list.
>
> I think of maybe using records, but I don't see quite how.
>
> Any suggestions?
>
> --Gil
>
>
> _______________________________________________
> 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
_______________________________________________
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