• 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: Accessing a Record by variable
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessing a Record by variable


  • Subject: Re: Accessing a Record by variable
  • From: Ric Phillips <email@hidden>
  • Date: Wed, 14 Feb 2001 10:25:10 +1100

> From: email@hidden (Douglas Wagner)

>
> Hello:
>
> I'd like to be able to access an AS record using a variable.
>
> set aMth to "Feb"
> set theMths to {Jan:"1", Feb:"2", Mar:"3", Apr:"4", May:"5", Jun:"6",
> Jul:"7", Aug:"8", Sep:"9", Oct:"10", Nov:"11", Dec:"12"}
> set mthNum to aMth in theMths
>
> what I'd like to get is --> 2
>
> I'm astonished this doesn't work. Is there an elegant alternative?
>
> Thanks and have a good day: Douglas Wagner

Try the following. (Don't forget the line continuation character.)

-----------------------------------------------------

set theMonths to {{mthName:"jan", mthNum:"1"},
{mthName:"feb", mthNum:"2"},
{mthName:"mar", mthNum:"3"},
{mthName:"apr", mthNum:"4"},
{mthName:"may", mthNum:"5"},
{mthName:"jun", mthNum:"6"}, >
{mthName:"jul", mthNum:"7"},
{mthName:"aug", mthNum:"8"},
{mthName:"sep", mthNum:"91"},
{mthName:"oct", mthNum:"10"},
{mthName:"nov", mthNum:"11"},
{mthName:"dec", mthNum:"12"}}

set monthToFind to "feb"

repeat with thisMonth in theMonths

if the mthName of thisMonth = monthToFind then
set monthNumber to the mthNum of thisMonth
end if

end repeat

-----------------------------------------------------

In this example monthNumber inside the repeat block will
Be set to "8"

Ric Phillips

Computer Laboratory Support Officer
Faculty of Humanities and Social Sciences
La Trobe University
9479 2792


  • Prev by Date: Re: Accessing a Record by variable
  • Next by Date: Re: Help needed AS & PhotoScripter
  • Previous by thread: Re: Accessing a Record by variable
  • Next by thread: Re: Accessing a Record by variable
  • Index(es):
    • Date
    • Thread