• 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
Scripting the AppleScript Editor
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Scripting the AppleScript Editor


  • Subject: Scripting the AppleScript Editor
  • From: Gil Dawson <email@hidden>
  • Date: Sat, 09 Jun 2012 13:26:47 -0700

Hi--

Both the AppleScript Editor and Smile give the same result to this problem, so I figure it has to be me.  Perhaps someone can help me understand why this isn't working:

--There is a file on my machine, alone in its folder: 
set TheTargetFile to ¬
(alias POSIX file "/Users/gil/Desktop/Afolder/AScript")

--This code works:
tell application "AppleScript Editor" to ¬
set TargetScript to open TheTargetFile
TargetScript --> works fine
close the TargetScript

--But my goal is to scan the folder...
set AFolder to ¬
(alias POSIX file "/Users/gil/Desktop/Afolder")

tell application "Finder" to ¬
set FilesInAFolder to files in AFolder
set AFile to (item 1 of FilesInAFolder)
tell application "AppleScript Editor" to ¬
set TargetScript to open AFile
TargetScript -->ERROR: TargetScript is not defined
close the TargetScript -- not executed


Now the really curious evidence comes from the Event Log (Events and Replies) in AppleScript Editor after running the above code:

tell application "AppleScript Editor"
open alias "MBProHD:Users:gil:Desktop:AFolder:AScript"
--> document "AScript"
close document "AScript"
end tell
tell application "Finder"
get every file of alias "MBProHD:Users:gil:Desktop:AFolder:"
--> {document file "AScript" of folder "AFolder" of folder "Desktop" of folder "gil" of folder "Users" of startup disk}
open document file "AScript" of folder "AFolder" of folder "Desktop" of folder "gil" of folder "Users" of startup disk

Result:

error "The variable TargetScript is not defined." number -2753 from "TargetScript"

The first time through, AppleScript Editor opens AScript, which works fine.
The second time, though, the Finder opens AScript, which doesn't work.  

Can anyone help me understand why the Finder is opening the file the second time?

I'm using MacOS 10.6.8, AppleScript 2.1.2, AppleScript Editor 2.3 (118), Smile 3.5.3 (build 611).

I'd appreciate your suggestions.

--Gil
 _______________________________________________
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: Scripting the AppleScript Editor
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Re: Hiding terminal on app launch
  • Next by Date: Re: Scripting the AppleScript Editor
  • Previous by thread: Re: Hiding terminal on app launch
  • Next by thread: Re: Scripting the AppleScript Editor
  • Index(es):
    • Date
    • Thread