done this little Script to process QXP page to PS files from one folder to another.
No probs.
Can skip duplicates
but I want to be able to track how many files were actually processed in the sub rout.
I Put a variable in and tried to get the sub to add 1 to the ‘tracker’ and return the value every time a PS file was produced but I keep getting a ‘…returned of 0’ error.
You need to include a code snippet to demonstrate how you’re calling it.
Subroutines can return values, you simply need to assign the result to a variable like:
set subResult to doSubroutine()
display dialog subResult
on doSubroutine()
-- code goes here
set uselessNumber to (random number from 1 to 10)
-- return whatever value you like:
return uselessNumber
end doSubroutine
on PS_print(tracker, this_item, Output, new_name)
tell application “Finder”
if (exists item (the Output & new_name)) then
return
else
set tracker to tracker +1
tell application “QuarkXPress Passport”
activate
open this_item remap fonts no
my page_setup()
tell document 1
set PS_Path to coerce (Output & new_name) to string
print PostScript file PS_Path
end tell
close document 1 saving no
end tell
return tracker
end if
end tell
end PS_print
Here is the whole script. I don’t think this is complete as after I couldn’t get ‘tracker’ to work I butchered it!!
set tracker to 0 as integer
tell application “Finder”
activate
set the source_folder to (choose folder with prompt “Pick the folder containing the Files you wish to convert to PostScript:”)
–display dialog “This will create 12x4 material!” & return & “Continue?” with icon caution
set the item_list to list folder source_folder without invisibles
set source_folder to source_folder as string
– Where to put he files
set Output to (“DCMac1:Desktop Folder:Output:”) as string
-- Repeat routine
repeat with i from 1 to number of items in the item_list
set this_item to item i of the item_list
set this_item to (source_folder & this_item) as alias
set this_info to info for this_item
set the current_name to the name of this_info
set the new_name to ("A" & characters 1 thru 7 of the current_name & ".pos") as string
my PS_print(tracker, this_item, Output, new_name)
display dialog returned of my PS_print(tracker, this_item, Output, new_name)
--set tracker to returned of my PS_print(tracker, this_item, Output, new_name)
display dialog tracker
end repeat
-- Finish up
tell application "Finder"
activate
set item_count to the number of items in item_list as string
if tracker = 0 then
set tracker to tracker as string
beep 1
display dialog {tracker & "No files were produced as only duplicates exist."} buttons "OK, I Guess!" with icon 1
else
set tracker to tracker as string
beep 2
display dialog {tracker & " of " & item_count & " files were produced."} buttons "Cool" with icon 1
end if
end tell
end tell
– Page set-up routine
on page_setup()
tell application “QuarkXPress™”
tell document 1
tell print setup
ignoring white space and case
set printer type to “CXP6K3_2”
set reduce or enlarge to 100
set registration marks to off
set orientation to portrait
set paper size to “Custom”
set paper width to 304.8
set paper height to 101.6
set page position to center position
end ignoring
end tell
end tell
end tell
end page_setup
– Print and duplicate check routine
on PS_print(tracker, this_item, Output, new_name)
tell application “Finder”
if (exists item (the Output & new_name)) then
set tracker to tracker
return (tracker) as number
else
tell application "QuarkXPress™"
activate
open this_item remap fonts no
my page_setup()
tell document 1
set PS_Path to coerce (Output & new_name) to string
print PostScript file PS_Path
end tell
close document 1 saving no
end tell
set tracker to (tracker) + 1
display dialog tracker
return (tracker) as number
end if
end tell