• 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: Variable names on the fly?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Variable names on the fly?


  • Subject: Re: Variable names on the fly?
  • From: Richard 23 <email@hidden>
  • Date: Mon, 15 Jan 2001 21:29:00 -0800

>Hi:
>
>Can someone kindly explain why this doesn't work? I thought I would
>construct a property name on the fly in order to get the month number, but I
>get an error. (Can't get...) But if I use a propList like {jug: "1"} and ask
>for the jug of the propList I always get the correct value, a 1.
>
>Perhaps it is not possible to construct variable names on the fly?
>
>-----start
> ....
>---------stop
>
>Thanks for any help!
>
>asd
>_________________________________________________________________
>Get your FREE download of MSN Explorer at xxxxxxxxxxxxxxxxxxxxxxx

First of all, if you want to get help please don't spam me with ads
for a product that comes straight from satan's backside.

Second. Here's your answer.

-- ---------------------------------------------------------
-- Preprocessed by Convert Script 1.0d2
-- ---------------------------------------------------------
set theDate to (date string of (current date))
set theMonth to word 2 of theDate
display dialog (theMonth) -- "January"

set monthProps to {mJanuary:"1", mFebruary:"2", mMarch:"3", mApril:==>
"4", mMay:"5", mJune:"6", mJuly:"7", mAugust:"8", mSeptember:==>
"9", mOctober:"10", mNovember:"11", mDecember:"12"} ==>


set mMonth to ("m" & theMonth)

-- set monthNum to mMonth of monthProps --ERROR
set monthNum to GetProp(monthProps, "m" & theMonth)
display dialog mMonth & " (" & monthNum & ") " -- "mJanuary (1)"


-- ----------------------------------------------
-- get property from script or record (by R23)
-- ----------------------------------------------
on GetProp(theObj, theProp)
tell (run script "me
on f(theObj)
return theObj's " & theProp & "
end f") to return f(theObj)
end GetProp
-- ---------------------------------------------------------

R23

ads masquerading as signatures should be banned.




___________________________________________________________________
while surfing the web be sure to visit R23's One Step Beyond
otherwise people will know you're an idiot and you don't want that.
___________________________________________________________________
http://homepage.mac.com/richard23/


  • Follow-Ups:
    • Re: Variable names on the fly?
      • From: Paul Berkowitz <email@hidden>
    • Re: Variable names on the fly?
      • From: Shane Stanley <email@hidden>
    • Re: Variable names on the fly?
      • From: Paul Berkowitz <email@hidden>
  • Prev by Date: Re: Variable names on the fly?
  • Next by Date: Re: Reference variables
  • Previous by thread: Variable creation by script
  • Next by thread: Re: Variable names on the fly?
  • Index(es):
    • Date
    • Thread