Hi
i need some help for a simple handler that doesn’t work, like this:
on get_data(input)
–my script
end get_data
.in conjunction with the ‘image capture’ plugin of automator.
in short, i want to run a script instead to use ‘Image capture’ to get the images off from my digital camera and to download these to my HD.
on run {input, parameters}
set output to get_data(input)
return output
end run
on get_data(inputList)
set someData to missing value
repeat with anItem in inputList
-- do something with anItem
end repeat
return someData
end get_data
this run handler ist designated handler for a run AppleScript action
This line sets the variable someData to a defined value.
In case someData won’t be changed in the repeat loop the handler returns at least missing value.
Hi,
I get an error when I connect my camera. The repeat handler fails. And inputList returns žcurrent application"
How to declare inputList?
I used:
on run (input) --{input, parameters}
set output to get_data(input)
return output
end run
on get_data(inputList)
set someData to missing value
--other commands
my run_thru()
return someData
end get_data
on import_f(inputList)
tell application žx"
with timeout of t_lim seconds
repeat with i in inputList
try
set h to import (i as alias) at catalog 1
end try
end repeat
end timeout
end tell
end import_f
the run_thru() handler is not defined
the import_f() handler will never be called t_lim is not defined.
Try something like this
property t_lim : 600
on run {input, parameters}
set output to import_f(input)
return output
end run
on import_f(inputList)
set importedItems to {}
tell application "x"
with timeout of t_lim seconds
repeat with i in inputList
try
set h to import (i as alias) at catalog 1
set end of importedItems to contents of i
end try
end repeat
end timeout
end tell
return importedItems
end import_f
Stefan, sometimes I scribble a bit to fast…
I tried to change things, but without success. (the script is saved as application)
on run (input) --{input, parameters}
set output to get_data(input)
return output
end run
on get_data(inputList)
tell app žx"
if number of items in catalog 1 is 0 then my import_f(inputList)
end
--my run_thru()
end get_data
on import_f(inputList)
set t_lim to 15 * minutes
set inputList to inputList as list
--import picts
set importedItems to {}
tell application žx"
with timeout of t_lim seconds
repeat with i in inputList
--try
--display dialog (i as text)
set h to import (i as alias) at catalog 1
set end of importedItems to contents of i
--end try
end repeat
end timeout
end tell
return importedItems
end import_f
Automator is handy, but this approach doesn’t work as standalone application too ?
i mean, an application or a script should do the same?
if not, i’ve to trash my script…