• 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: Replacing Codes with Text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Replacing Codes with Text


  • Subject: Re: Replacing Codes with Text
  • From: Andy Wylie <email@hidden>
  • Date: Sat, 16 Jun 2001 12:13:29 +1200

on 16/6/01 2:40 am, email@hidden at email@hidden wrote:

> I have a list of codes that are abbreviations for full names of Sunday
> comics. At a point in my script, I need to replace the codes in that list
> with the full comic name. I have been unable to come up with an idea of how
> to approach this.
>
> The actual list would normally contain 15-20 codes out of a 175 different
> possibilities. Here is a short sample of the list I am dealing with.
>
> List 1
> {"agn", "bal", "bmp", "bof"}
>
> I need to replace those items with:
> {"Agnes", "Baldo", "Speed Bump", "Mister Boffo"}
>
> I want to do it as a repeat loop, and treat each item separately, as I
> actually have to do a few other things with each code at this point of the
> script.
>
> Is there any way I could set up a text file with all 175 codes and what they
> equal, along the lines of:
> agn = Agnes
> bal = Baldo
> bmp = Speed Bump
> bof = Mister Boffo
> then have the script call it in as a variable and compare one list to the
> other and build a new list?
>
> I am open to any ideas at all, and will use other osax if it will make it
> easier.
>
I like Paul's solution but here's simple nested list method...

set alist to {{"agn", "Agnes"}, {"bal", "Baldo"}, {"bmp", "Speed Bump"},
{"bof", "Mister Boffo"}}

set x to "bmp"

repeat with i from 1 to count of alist
if item 1 of item i of alist is x then
set fullname to item 2 of item i of alist
end if
end repeat
fullname
-- "Speed Bump"

__we call those 'Judder Bars'... no you can't eat them__ Andy


  • Follow-Ups:
    • Learning Applescript for text manipulation?
      • From: "Joseph A. Weaks" <email@hidden>
References: 
 >Replacing Codes with Text (From: email@hidden)

  • Prev by Date: Re: How to 'load' osaxen
  • Next by Date: Re: Replacing Codes with Text
  • Previous by thread: Re: Replacing Codes with Text
  • Next by thread: Learning Applescript for text manipulation?
  • Index(es):
    • Date
    • Thread