• 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: Can't tell an application to open
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can't tell an application to open


  • Subject: Re: Can't tell an application to open
  • From: Laine Lee <email@hidden>
  • Date: Sun, 20 Feb 2011 14:39:15 -0600
  • Thread-topic: Can't tell an application to open

Provided ³theFile² is an hfs file path (colon-delimited text), this should
work (it did for me, credit goes to Shane's book):

tell current application to tell application "TextWrangler" to open theFile

I created a file called new.txt and defined "theFile" this way:
set theFile to (((path to desktop) as text) & "new.txt")

Laine Lee

On 2/20/11 2:32 PM, "Dave" <email@hidden> wrote:

>> On Feb 20, 2011, at 11:48 AM, Alex Zavatone wrote:
>>
>>> try this:
>>>
>>> tell application "Finder" to open theFile with application "TextWrangler"
>
> I can't get that line to compile in XCode or Script Editor/Debugger. (Also
> tried parens around the last part.)
> It gets:
>
> Expected "given", "with", "without", other parameter name, etc. but found """.
>
>
> For those interested, I've managed the following huge workaround, at least for
> TextWrangler, although unlike the original open command this could go to the
> wrong window if more than one window has the same name:
>
> property DebugLogName : "HotLog Log" -- log file name
> property DebugLogDir : "/tmp/"
> property DebugLogPath : DebugLogDir & DebugLogName -- path to use
>
> on WriteLineTextWrangler(logLine)
>   set theFile to POSIX file DebugLogPath
>   tell application "TextWrangler"
>     try
> (*  THIS DOESN'T WORK IN APPLESCRIPT OBJECTIVE-C Snow Leopard 10.6.6
> The open always goes to the script and not the tell
> set textDocument to open theFile
> *)
> set textDocument to first document whose name is DebugLogName
>     on error
>         -- document not in a window
>         try
> set theAlias to theFile as alias
> on error
> -- file does not yet exist
> set textDocument to make new document with properties {name:DebugLogName}
> try
> do shell script "touch " & quoted form of DebugLogPath
> set theAlias to theFile as alias
> save textDocument to theAlias
> end try
> end try
>     end try
>     tell text of textDocument -- won't work as one tell line
>         make new line with properties {contents:logLine & return}
>    end tell
>     -- scroll window to the bottom
>     tell window of textDocument to select insertion point after last character
>   end tell
>
>
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> applescriptobjc-dev mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> a.edu
>
> This email sent to email@hidden


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
applescriptobjc-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Can't tell an application to open (From: Dave <email@hidden>)

  • Prev by Date: Re: Can't tell an application to open
  • Next by Date: Re: Can't tell an application to open
  • Previous by thread: Re: Can't tell an application to open
  • Next by thread: Re: Can't tell an application to open
  • Index(es):
    • Date
    • Thread