Re: Re[2]: tell app, name in string var
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