I have what I’m sure is a simple question, but I’m stumped.
I’m making a drag and drop ASS application to collect and set print setup properties for batch printing a number of quark files. I have a working AS droplet I had built earlier but can’t seem to figure out how to make the “on open names” and “on clicked” parts of the ASS app work together. The application should work like this.
- drag-and-dropped files activate application
- window opens and prompts user for input
- input data is checked for basic errors
- data is saved to a string
- application cycles through dropped files (sorts files from folders) and sends each file to print in Quark using the print setup parameters from the saved string
I had thought that the “on open names” part would be the main script and that data returned from after the “on clicked” handler ran would cause it to cycle through the names files.
Any advice or recommendations as to where I can read more about drag and drop ASS apps would be great. Thanks.
on open names
set specs_list to {}
set click_done to false
if click_done is true then
repeat with i from 1 to the count of names
set this_item to (item i of names)
set the item_info to info for this_item
if folder of the item_info is true then
my process_folder(this_item, specs_list)
else if (alias of the item_info is false) then
my process_item(this_item, specs_list)
end if
end repeat
end if
end open
on idle theObject
(Add your script here.)
end idle
on clicked theObject
–
set theWindow to window of theObject
set PPD_spec to contents of button “PPD_spec” of theWindow
–CHANGES PRINTYER TYPE DATA FROM NUMBER TO STRING–
if PPD_spec = 0 then
set PPD_spec to “GCC Elite XL 20/600” as text
else if PPD_spec = 1 then
set PPD_spec to “HP LaserJet 6P/6MP” as text
else if PPD_spec = 2 then
set PPD_spec to “HP Color LaserJet 8550” as text
end if
–
set Color_spec to contents of button “Color_spec” of theWindow
–CHANGES PRINT COLOR FROM NUMBER TO STRING–
if Color_spec = 0 then
set Color_spec to “greyscale” as text
else if Color_spec = 1 then
set Color_spec to “black and white” as text
else if Color_spec = 2 then
set Color_spec to “composite CMYK” as text
end if
–
set Scale_spec to 401
repeat while Scale_spec < 25 or Scale_spec > 400
try
set Scale_spec to contents of text field “Scale_spec” of theWindow as text
set Scale_spec to Scale_spec as integer
on error
display dialog “Reduce/enlarge value must be a number between 25 and 400.”
if scale_var > 400 or scale_var < 25 then
display dialog “Reduce/enlarge value must be a number between 25 and 400.”
end if
end try
end repeat
–
set Reg_spec to contents of button “Reg_spec” of theWindow
–CHANGES REGISTRATION MARK INFO FROM NUMBER TO STRING–
if Reg_spec = 0 then
set Reg_spec to “off” as text
else if Reg_spec = 1 then
set Reg_spec to “off center” as text
else if Reg_spec = 2 then
set Reg_spec to “centered” as text
end if
–
set Collate_spec to (state of button “Collate_spec”) of theWindow
–
set Sep_spec to (state of button “Sep_spec”) of theWindow
–
set Spread_spec to (state of button “Spread_spec”) of theWindow
–
if current row of matrix “Orient_spec” of theWindow is 1 then
set Orient_spec to true as boolean
else
set Orient_spec to false as boolean
end if
–
set Num_spec to 21
repeat while Num_spec is greater than or equal to 21
try
set Num_spec to contents of text field “Num_spec” of theWindow as integer
on error
display dialog “Number of copies must be a whole number.”
if Num_spec > 120 or Num_spec < 1 then
display dialog “Number of copies must be beteen 1 and 20.”
end if
end try
end repeat
–
set specs_list to {Orient_spec, PPD_spec, Color_spec, Spread_spec, Scale_spec, Reg_spec, Sep_spec, Collate_spec, Num_spec}
display dialog specs_list as text
return specs_list
set click_done to true
quit theObject
end clicked
– this sub-routine processes folders
on process_folder(this_folder, specs_list)
set names to list folder this_folder without invisibles
repeat with i from 1 to the count of names
set this_item to alias ((this_folder as text) & (item i of names))
set the item_info to info for this_item
if folder of the item_info is true then
process_folder(this_item, specs_list)
else if (alias of the item_info is false) then
my process_item(this_item, specs_list)
end if
end repeat
end process_folder
– this sub-routine prints the files (here’s where the real work happens)
on process_item(this_item, specs_list)
tell application “Finder”
open item this_item
end tell
tell application “QuarkXPress Passport”
activate
tell print setup of document 1
--
if (item 1 of specs_list) is false then
set orientation to portrait
else
set orientation to landscape
end if
--
set printer type to item 2 of specs_list as text
--
if (item 3 of specs_list) is "composite CMYK" then
set print colors to composite CMYK
else
if (item 3 of specs_list) is "black and white" then
set print colors to black and white
else
set print colors to grayscale
end if
end if
--
if item 4 of specs_list = 0 then
set print spreads to true as boolean
else
set print spreads to false as boolean
end if
--
set reduce or enlarge to ((item 5 of specs_list as text) & "%")
--
if (item 6 of specs_list) is "centered" then
set registration marks to centered
else
if (item 6 of specs_list) is "off center" then
set registration marks to off center
else
set registration marks to off
end if
end if
end tell
--
set separation to item 7 of specs_list as boolean
--
set collate to item 8 of specs_list as boolean
--
print document 1 copies (item 9 of specs_list as integer)
close document 1 saving no
end tell
end process_item
end clicked