Page 1 of 1

error "Expected “end” but found “on”."

PostPosted: Fri Aug 18, 2017 1:14 pm
by Uhlhorn
Hi,
I try to use an Applescript to set a condition. But I always get an error. What is going wrong?
And the script is from this page:
https://www.noodlesoft.com/manual/hazel ... avascript/

Code: Select all
on hazelMatchFile(theFile, inputAttributes)
    — Add your logic here.
    — ‘theFile’ is an alias to the file that matched.
    — ‘inputAttributes’ is an AppleScript list of the values of any attributes you told Hazel to pass in.
    — Be sure to return true or false (or optionally a record) to indicate whether the file passes this script.
end hazelMatchFile


Image

Re: error "Expected “end” but found “on”."

PostPosted: Mon Aug 21, 2017 10:40 am
by Mr_Noodle
That template is for external scripts. For embedded scripts, just enter the script you want to use.

Re: error "Expected “end” but found “on”."

PostPosted: Mon Aug 21, 2017 11:34 am
by Uhlhorn
Yes, I figured it out too. The script have to look like this:
(The linked web page should get a clue!)

Code: Select all
set root_fol to theFile

tell application "Finder"
   set files_ to count files of entire contents of root_fol
end tell

if files_ is 0 then
   return false
else
   return true
end if

Re: error "Expected “end” but found “on”."

PostPosted: Tue Aug 22, 2017 10:38 am
by Mr_Noodle
I'll update the manual in a future patch.