handler input issue

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.

Hi,

the syntax should look like


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


Hi Stefan
excuse for the silly question, but why we should need
parameter?
and
set someData to missing value?

-curiosity-

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 

a lot of problems

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…:wink:
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

I thought, you were talking about an Automator action script.

How does the scipt know, what “items in catalog 1” is?
AppleScript has no idea about catalog

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…

edit:
there is a tell-statement before ‘catalog’.

Probably it works, but then there’ s another question: where does the input come from?

the sources files are images from a iPod or digital camera.
i hoped… to pipe images as input into my script/application.

Automatic input in AppleScript is only possible with event handlers like folder action scripts or iChat or Mail event handlers.

Let me understand, we needs selected files in “finder” or “Image capture” to get the right input for a successive pipe into scripts and applications?

Yes, input can be

¢ selection in Finder
¢ result of choose file,
¢ on open handler (droplet)
¢ folder action event handler
¢ launchd agent monitoring a folder

AFAIK image capture can not be captured by AppleScript