Re: Accessing a Record by variable
Re: Accessing a Record by variable
- Subject: Re: Accessing a Record by variable
- From: "Arthur J Knapp" <email@hidden>
- Date: Tue, 13 Feb 2001 17:42:26 -0500
>
Date: Tue, 13 Feb 2001 13:34:06 EST
>
Subject: Re: Accessing a Record by variable
>
>on 2/12/01 8:02 PM, Douglas Wagner at email@hidden wrote:
>
>> set aMth to "Feb"
>
>> set theMths to {Jan:"1", Feb:"2", Mar:"3", Apr:"4", May:"5", Jun:"6",
...
>
>> set mthNum to aMth in theMths
>
>> what I'd like to get is --> 2
>
>> I'm astonished this doesn't work.
Astonished!
Well, I'm afraid there may be all sorts of astonishing
disappoints in your future regarding AppleScript. ;-)
>
>> Is there an elegant alternative?
This should do for this specific purpose:
property kStrMonths : "JanFebMarAprMayJunJulAugSepOctNovDec"
on monthIndex(mon)
-- Note, mon must be case-sensitive
set x to offset of mon in kStrMonths
if (x = 0) then
return 0 -- or cause error
else
return x div 3 + 1
end if
end monthIndex
monthIndex("Feb") -- > 2
--
{
Arthur J Knapp, of STELLARViSIONs ;
http://www.STELLARViSIONs.com ;
mailto:email@hidden ;
"...it's not my birthday,
it's not today..."
}