Re: Replacing Codes with Text
Re: Replacing Codes with Text
- Subject: Re: Replacing Codes with Text
- From: email@hidden
- Date: Fri, 15 Jun 2001 20:27:33 -0400
On Date: Fri, 15 Jun 2001 09:40:19 -0500, email@hidden asked,
>
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"}
For structures like this, I use a combination of Sigma's Coercions, ACME lookup
field, ACME Script Widgets, and Akua Sweets.
>
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?
Since there is a large number of possibilities and only a few codes in the
actual list, I'd scan through the lists and search the translation table for
each. You can start with your translation table as a text file, as you suggest,
in any easy-to-parse form. Akua Sweets' "decompose" does this easily in one
command. So, break this input down into,
{ {"agn", "Agnes" }, {"bal", "Baldo"},...}
Now, you can sort this list using "order list" from Akua Sweets. Then, scan
through your input list, do a binary search for the three-letter code (referring
to "item 1 of item N of codetable" and moving N up or down by powers of two
depending on whether that item is less than or greater than what you are
searching for.) Once you find it, put the corresponding value on the end of
your output list.
--
Scott Norton Phone: +1-703-299-1656
DTI Associates, Inc. Fax: +1-703-706-0476
2920 South Glebe Road Internet: email@hidden
Arlington, VA 22206-2768 or email@hidden