Page 1 of 1

Question about an embedded script

PostPosted: Tue Apr 22, 2014 10:45 am
by LaurentR2D2
Hello,

I've been given this script :

on open csvFiles
repeat with thisFile in csvFiles
set fp to open for access thisFile with write permission
set csvText to read fp
set csvSplitText to tid of csvText by ","
set csvNewText to tid of csvSplitText by ";"
set eof fp to 0
write csvNewText to fp
close access fp
end repeat
end open

on tid of input by delim
-- handler for text items

set {oldTID, my text item delimiters} to {my text item delimiters, delim}
if class of input is list then
set output to input as text
else
set output to text items of input
end if
set my text item delimiters to oldTID
return output
end tid

It works fine when converted as application, but when I try to use it as embedded script with Hazel, I get an error :

"end" intended but "on" found. What should I do to fix that ?

I've seen that I should put theFile in the script. Is it in replacement of csvFiles or thisFile ?

Thank you

Re: Question about an embedded script

PostPosted: Tue Apr 22, 2014 2:59 pm
by Mr_Noodle
Read the help on AppleScript. You need to use a specific handler for Hazel and if it's embedded, you can't have handlers at all.