Hi,
I have a script wich save’s a quark document to version 5.0, but it only works with already existing documents. When I create a new document and use the script, there is an error.
Script can’t give file a version number 50
Can you help me??
tell application "QuarkXPress Passport"
activate
if document 1 exists then
if file path of document 1 is null then
set theFile to (choose file name with prompt "Save QXP v5 document as...")
else
set theFile to file path of document 1
end if
save document 1 in theFile version vers 50 --error with new document
-- script is not able to save in version 50
else
beep
display dialog "No document is open." buttons {"Cancel"} default button 1
end if
end tell
Bert
What I’ve done isn’t quite working, I seem to be able to get smaller chunks to work but not when I put them together.
I may be overcomplicating this script but here’s what I’m trying to do →
Using a Folder Action, when a file is FTP’d to this folder, take each line in the file and send it as a parameter to another script, repeat until all lines have been read, when the file is finished being read send it to another folder.
Each line of the file added to the folder contains a line text that’s a path to a control file that the other script will process.
I’m also trying to have an error handler that both displays and emails any errors.
I also need check to see if an SMB share is mounted for the other script.
on adding folder items to this_folder after receiving these_items
–check to see if share mounted
–this share needs to be mounted for other script to find the locations
tell application “Finder”
if not (exists “SHARE”) then
mount volume “smb://user:password@Server/SHARE”
end if
end tell
try
–extract the lines of the file as the parameter
tell application “Finder”
set the_file to items of this_folder
end tell
set the_file to item 1 of the_file as alias
set the_paragraphs to paragraphs of (read the_file)
set old_atid to AppleScript’s text item delimiters
repeat with i from 1 to count of the_paragraphs
set this_paragraph to (item i of the_paragraphs)
set AppleScript’s text item delimiters to {tab}
set the_base_name to text item 1 of this_paragraph
set AppleScript’s text item delimiters to {“”}
set new_name to the_base_name
repeat
try
get new_name as alias
set new_name to the_base_name
on error
exit repeat
end try
end repeat
–send the paramter to another script
tell application “Finder” to set thePath to “ServerHD:Library:Scripts:” as string
set remote_script to thePath & “other_script”
set new_name to “Parameter 1”
run script file remote_script with parameters {x}
return
end repeat
–error handler to display and email error
set AppleScript’s text item delimiters to old_atid
on error the_error
display dialog the_error buttons {“OK”} default button 1 with icon 0 giving up after 120
tell application “Mail”
set theMessage to (make new outgoing message at end of outgoing messages)
set default_address to “somebody@somewhere.com”
set default_content to the_error
set default_subject to “Script Error!”
tell theMessage
set visible to true
make new to recipient at end of to recipients with properties {address:default_address}
set subject to default_subject
set content to default_content
send theMessage
end tell
end tell
return
end try
end adding folder items to
Sorry - didn’t mean to post reply with new topic
Well actually seems to be my topic but there’s a post before my first one. Maybe we posted at same time??
Anyway…
made some changes getting things to work better but still not quite working…
on adding folder items to this_folder after receiving these_items
tell application “Finder”
if not (exists “SAHRE”) then
mount volume “smb://user:password@server/SHARE”
end if
end tell
try
tell application “Finder”
set the_file to items of this_folder
end tell
set the_file to item 1 of the_file as alias
set the_paragraphs to paragraphs of (read the_file)
set old_atid to AppleScript’s text item delimiters
repeat with i from 1 to count of the_paragraphs
set this_paragraph to (item i of the_paragraphs)
set AppleScript’s text item delimiters to {tab}
set the_base_name to text item 1 of this_paragraph
set AppleScript’s text item delimiters to {“”}
set new_name to the_base_name
repeat
try
get new_name as alias
set new_name to the_base_name
on error
exit repeat
end try
end repeat
tell application “Finder” to set thePath to “ServerHD:Library:Scripts:” as string
set remote_script to thePath & “other_script.scpt”
set new_name to “Parameter 1”
run script file remote_script with parameters {new_name}
return
end repeat
set AppleScript’s text item delimiters to old_atid
on error the_error
display dialog the_error buttons {“OK”} default button 1 with icon 0 giving up after 120
tell application “Mail”
set theMessage to (make new outgoing message at end of outgoing messages)
set default_address to “somebody@somewhere.com”
set default_content to the_error
set default_subject to “Script Error!”
tell theMessage
set visible to true
make new to recipient at end of to recipients with properties {address:default_address}
set subject to default_subject
set content to default_content
send theMessage
end tell
end tell
return
end try
tell application “Finder”
move item_ to “:ServerHD2:Processed” with replacing
delete item_
end tell
end adding folder items to