open question

As I was studying the code for Apple’s “Build Web Page” script, I have a question or two. Here is a portion of the code:

...
on run
	display dialog "Build a web page from files or a folder."
	set someFile to choose folder with prompt "Choose a folder of images"
	open someFile
end run


on open draggeditems
	set sourcefiles to findImagesIn(filelistFromSelection(draggeditems))
	if ((count items of sourcefiles) > 0) then makePage(sourcefiles)
end open


on makePage(sourcefiles)
	tell application "Image Capture Scripting" to launch
...

1- After a folder is chosen in the first section, how does the script move down to the “makePage” portion? Or what is it doing that looks like it moved on down?

2- Maybe part of the answer to ‘1’: What is being opened on the “open someFile” line?

3- What or where is “Image Capture Scripting”? I did a find from the Finder and only found “Image Capture Scripting.crash.log”.

  1. I haven’t ran the script, so I’m not sure what you mean by “looks like it moved on down” but it looks like it’s another handler in the script to do more stuff.

  2. someFile is being used as a variable for the folder of pictures.

  3. The Image Capture Scripting is a special background appliction used by the ColorSync and Image Capture applications to scale and rotate images. See the web page below for more info on Image Capture Scripting…

http://www.apple.com/applescript/image_capture/

The part of the code that says:

if ((count items of sourcefiles) > 0) then makePage(sourcefiles) 

can be translated as "if the number of items in ‘sourcefiles’ is greater than 0 then call the subroutine called ‘makePage’ passing in the variable ‘sourcefiles’.

The open handler is passed in a list of the files dropped on the script icon. The script can assign a variable name to this list so it can reference the files. In this case, ‘on open draggedItems’ basically says "when launched, assign the name ‘draggedItems’ to the list of files dropped on me’.

Image capture Scripting is located at /System/Library/ScriptingAdditions/Image Capture Scripting.app. If it’s not installed on your machine, you can get it from http://www.apple.com/applescript/image_capture/

Thank you for the help. I’m starting to get it. With the hundreds and thousands of pages of documents in the various Apple publications it’s hard to get THE answer for some of the the less obvious questions. Hopefully my questions here benefit other people on the front-side of the learning curve.

For 1- (&2-) What I have come to understand is the “open somefile” gets passed to the “on open draggeditems” section. The “open” in this case telling AppleScript to open (with the passed parameter). My first thought was that it was telling Finder to ‘open.’ Which didn’t make sense.

For 3- Thanks for the answer. Is there someplace I can go in Apple’s documents &/or website to find these “special background applications”?