• 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: Calling a property by using a string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calling a property by using a string


  • Subject: Re: Calling a property by using a string
  • From: Emmanuel <email@hidden>
  • Date: Mon, 25 Sep 2006 19:14:26 +0200

At 12:41 PM -0400 9/25/06, Mark J. Reed wrote:
On 9/25/06, Chris Tangora <email@hidden> wrote:
property Average_Test : "Please Don't Work"
property Good_Test : "Shouldn't Work"
property Great_Test : "This worked"

set this to "Great"
set test to "_Test"

set thistest to (this & test)

log thistest

What you want is dynamic code evaluation, a.k.a. second-level evaluation, which in other languages tends to be embodied by a function named "eval". In AppleScript the only way I know of to do this is to call "run script" on a string whose value is the code you want to run; unfortunately, such a dynamic script object has no access to the variables and properties of the surrounding code, so that won't help your particular problem.

Mark means the following (OMM, returns "This worked"). Like he says, the example will break as soon as you start doing something interesting out of it.


property Average_Test : "Please Don't Work"
property Good_Test : "Shouldn't Work"
property Great_Test : "This worked"

set this to "Great"
set test to "_Test"

set thistest to (this & test)

run script ("my " & thistest)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Calling a property by using a string (From: Chris Tangora <email@hidden>)
 >Re: Calling a property by using a string (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: [OT] Of names and babington's
  • Next by Date: Re: AppleScript runs slow on Intel Macs
  • Previous by thread: Re: Calling a property by using a string
  • Next by thread: Re: Calling a property by using a string
  • Index(es):
    • Date
    • Thread