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 |