Re: why won't this compile?
Re: why won't this compile?
- Subject: Re: why won't this compile?
- From: "Marc K. Myers" <email@hidden>
- Date: Fri, 28 Dec 2001 11:37:58 -0500
- Organization: [very little]
>
Date: Thu, 27 Dec 2001 22:32:22 -0700
>
Subject: why won't this compile?
>
From: "Donald S. Hall" <email@hidden>
>
To: AppleScript Mailing List <email@hidden>
>
>
This script compiles and runs fine (both OS 9.2.1, AS 1.6 & OS 10.1, AS 1.7)
>
>
--begin script 1 -------------------------------------
>
set theURL to "http://www.maccentral.com"
>
set theWindow to -1 -- top window
>
>
tell application "Internet Explorer"
>
OpenURL theURL toWindow theWindow Flags 7
>
end tell
>
--end script 1 ---------------------------------------
>
>
However, this script won't compile on either system:
>
>
--begin script 2 -------------------------------------
>
set theURL to "http://www.maccentral.com"
>
set theWindow to -1 -- top window
>
>
set browser to "Internet Explorer"
>
tell application browser
>
OpenURL theURL toWindow theWindow Flags 7
>
end tell
>
--end script 2 ---------------------------------------
>
>
Nor will this script:
>
>
--begin script 3 -------------------------------------
>
set theURL to "http://www.maccentral.com"
>
set theWindow to -1 -- top window
>
>
set browser to application "Internet Explorer"
>
tell browser
>
OpenURL theURL toWindow theWindow Flags 7
>
end tell
>
--end script 3 ---------------------------------------
>
>
In the latter two cases, "Check Syntax" produces an error message:
>
>
'Expected end of line, but found identifier.' The identifier highlighted is
>
theURL in the OpenURL statement.
>
>
What am I doing wrong, if anything?
You can't specify the application that way and expect it to compile.
Your compiler goes to an application's dictionary to translate
English-like code into machine-readable code. As there's no application
available at compile time and the commands aren't universal (i.e.
"open", "close", "activate", "quit", etc.), the compiler doesn't know
what to do with them. You can use the "double tell" technique or a
"using terms from" block to get around this, to some extent, but you
still have to name the application somewhere so the compiler knows what
it's working with.
Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074
[12/28/01 11:34:44 AM]