• 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: Re[2]: tell app, name in string var
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re[2]: tell app, name in string var


  • Subject: Re: Re[2]: tell app, name in string var
  • From: Zack Jarrett <email@hidden>
  • Date: Tue, 17 May 2011 07:28:02 -0700

There's a very ugly way to do this, and it's fragile, but it will work if you KNOW FOR SURE that the targeted application is on the system.

What you do is build up your desired script as a string so that AppleScript doesn't attempt to compile it at compile time.  The string will only be compiled at runtime (during the run script).  Doing this is klunky, fragile, and definitely ugly for longer scripts, but it can be an appropriate solution.

Here's an example, using your scenario:

set appName to "Microsoft Excel"
set s to "tell application " & quote & appName & quote & return & "return display alerts" & return & "end tell"
set theResult to run script s


This will result in a runtime exception if Excel doesn't exist on the system where this is running.

Good luck!
Zack

On May 17, 2011, at 6:07 AM, Leonid Bogdanov wrote:

> Shane,
>
>  Looks nice, but again, app name is hardcoded in one statement :)
>    using terms from application "Microsoft Excel"
>
>  and
>    using terms from application appName
>
>  doesn't work.
>
>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re[4]: tell app, name in string var
      • From: Leonid Bogdanov <email@hidden>
References: 
 >tell app, name in string var (From: Leonid Bogdanov <email@hidden>)
 >Re[2]: tell app, name in string var (From: Leonid Bogdanov <email@hidden>)

  • Prev by Date: Re: sending apple events to a remote Filemaker
  • Next by Date: Re[4]: tell app, name in string var
  • Previous by thread: Re: Re[2]: tell app, name in string var
  • Next by thread: Re[4]: tell app, name in string var
  • Index(es):
    • Date
    • Thread