Question about an embedded script

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Question about an embedded script 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
LaurentR2D2
 
Posts: 4
Joined: Thu Aug 01, 2013 8:28 pm

Re: Question about an embedded script 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.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support