Script that worked in the past now has problems in 3 places

Hello:

I have a script that worked in the past but is now giving me grief.

The script basically checks to see if it is an InDesign or Quark file, suppresses all missing font and image warnings, creates the PDF and places that pdf in a specified folder on my desktop called “Babs PDF Folder”
The InDesign part is working fine…The quark part is giving me these problems. I know what to put here and what to do, but I am still having trouble.

Problem 1- Suppress All warnings

I know I need to add the following line, But, I am not sure where to put it in the script.

Suppress All Warnings:true

Problem 2-pdf gets in the name twice
There is a line in the code:

set tempname to my add_extension(WorkingFile, newpart, "pdf")

I do NOT need to add pdf at the end, as it is already there. I tried to remove the pdf and leave the quotes, but what I get is “.” so the file get’s named starad…pdf.
If I try to remove the quotes and the comma, the script bombs.

Problem 3: Files won’t close despite line of code
I have a line of code that should be closing the file once done, but it doesn’t

close front document saving no

Anyone no why these 3 odd things are happening?

any help is greatly appreciated!
thanks!!
babs

Here are my problems.

That’s not a legal variable name. The colon whispers “I’m a script property”. Redo like so:

property suppressAllWarnings:true

and put at top of script.

Problem 2-pdf gets in the name twice
Don’t call that subroutine?
It looks like it is intended to receive a file name without extension, some string to add to the name, and the extension to stick on at the end.
The script should provide the extension-less name. Put in a “log WorkingFile” before calling the sub, and see what that returns.

That’s because you’re feeding two parameters to a subroutine that wants three.

Problem 3: Files won’t close despite line of code
Is that line in a tell block targeting the document’s application? Is the Quark version you’re using still the same as before?

Hello,
Thank you so much for getting back to me…
Here is the actual script, maybe that will help?
I put my response to your suggestions at the bottom of this post.

property Babs_Folder : "Babs PDF Folder"
property suppressAllWarnings : true
global deskPath
global PathToFolder
global PathToFolder2
global tempPictures


on open thefiles
	tell application "Finder"
		activate
		set tempPictures to (every item of (get selection)) -- MUST GET BEFORE MAKING FOLDERS
		if not (exists folder Babs_Folder) then make new folder with properties {name:Babs_Folder}
		set deskPath to desktop as text
		
		
		set PathToFolder to POSIX path of (deskPath & Babs_Folder)
		set PathToFolder2 to deskPath & Babs_Folder & ":"
	end tell
	my openfiles()
	say "Finished"
end open


on openfiles()

	try
		tell application "Finder"
			repeat with LoopFiles in tempPictures
				set foundImages to {}
				if kind of LoopFiles = "Folder" then
					try
						set foundImages to files of entire contents of LoopFiles as list
					on error
						set foundImages to files of entire contents of LoopFiles
					end try
				else
					if kind of LoopFiles is not in {"Volume", "Disk Image", "Application", "Web Internet Location", "Document", "Text Clipping"} then
						set end of foundImages to LoopFiles
					end if
				end if
				--set WorkingFile to item i of fileList
				repeat with WorkingFile in foundImages
					if not ((kind of WorkingFile starts with "Quark") or (kind of WorkingFile starts with "InDesign")) then
						activate
						display dialog "This file is not an InDesign or Quark document!" buttons "Skipping" default button "Skipping" with icon 0 giving up after 1
					else
						--Determine whether to use InDesign subroutines or Quark subroutines
						if (kind of WorkingFile starts with "InDesign") then -- Process as InDesign
							my createInDesignPDF(WorkingFile, PathToFolder2)
						else -- Process as Quark
							my createQuarkPDF(WorkingFile)
						end if
					end if
				end repeat
			end repeat
		end tell
	on error errmsg
		display dialog "OpenFiles." & return & errmsg giving up after 20
	end try
end openfiles


on createInDesignPDF(WorkingFile, savePath)
	set x to 0
	repeat
		if x = 0 then
			set newpart to ""
		else
			set newpart to " " & x
		end if
		tell application "Finder"
			set tempname to my add_extension(WorkingFile, newpart, "pdf")
			if not (exists file tempname in folder Babs_Folder) then exit repeat
		end tell
		set x to x + 1
	end repeat
	tell application "Adobe InDesign CS3"
		try
			try
				set user interaction level of script preferences to never interact
			end try
			open WorkingFile as alias
			delay 2
			repeat
				if exists document 1 then exit repeat
				delay 0.2
			end repeat
			set theProps to properties of PDF export preset "[Smallest File Size]"
			set newProps to {view PDF:false, crop marks:false, bleed marks:false, color bars:false, registration marks:false} & theProps
			set oldProps to properties of PDF export preferences
			set properties of PDF export preferences to newProps
			export front document format PDF type to (savePath & tempname) without showing options
			set properties of PDF export preferences to oldProps
			delay 1
			tell documents to close saving no
			try
				set user interaction level of script preferences to interact with all
			end try
		on error errmsg
			display dialog "CreateIndesignPDF." & return & errmsg giving up after 20
		end try
	end tell
end createInDesignPDF

on createQuarkPDF(WorkingFile)
	try
		set x to 0
		repeat
			if x = 0 then
				set newpart to ""
			else
				set newpart to " " & x
			end if
			tell application "Finder"
				set tempname to my add_extension(WorkingFile, newpart, "pdf")
				if not (exists file tempname in folder Babs_Folder) then exit repeat
			end tell
			set x to x + 1
		end repeat
		tell application "QuarkXPress"
			activate
			open WorkingFile as alias with «class SPRS»
			tell application "System Events" to tell process "QuarkXPress"
				click menu item "Layout as PDF..." of menu 1 of menu item "Export" of menu 1 of menu bar item "File" of menu bar 1
				delay 1
				keystroke tempname
				delay 1
				keystroke "G" using {shift down, command down}
				delay 1
				keystroke PathToFolder
				delay 1
				click button "Go" of sheet 1 of window "Export as PDF"
			end tell
			repeat 2 times
				delay 1
				activate
				tell application "System Events" to tell process "QuarkXPress"
					try
						if exists button "OK" of window 1 then
							click button "OK" of window 1
						end if
					end try
				end tell
			end repeat
			delay 1
			tell application "System Events" to tell process "QuarkXPress"
				try
					click button "Save" of window "Export as PDF"
				end try
			end tell
			repeat 4 times
				delay 1
				activate
				tell application "System Events" to tell process "QuarkXPress"
					try
						if exists button "OK" of window 1 then
							click button "OK" of window 1
						end if
					end try
					try
						if exists button "List Profiles" of window 1 then
							click button "Continue" of window 1
						end if
					end try
				end tell
			end repeat
			close front document saving no
		end tell
	on error errmsg
		display dialog "CreateQuarkPDF." & return & errmsg giving up after 20
	end try
end createQuarkPDF

on add_extension(WorkingFile, new_part, new_extension)
	try
		set this_info to info for WorkingFile as alias
		set this_name to the name of this_info
		set this_extension to the name extension of this_info
		if this_extension is missing value then
			set the default_name to this_name
		else
			set the default_name to text 1 thru -((length of this_extension) + 2) of this_name
		end if
		return (the default_name & new_part & "." & the new_extension)
	on error errmsg
		display dialog "add extension " & return & errmsg
	end try
end add_extension

Re: Problem 1:
I did add that suppress all warning to the top, but it is still asking for them?

Re: Problem 2:
I am not sure how to properly remove that subroutine, what I ever I try, the script doesn’t compile.

Problem 3:
I tried to put the tell block in a few places, but the document still wouldn’t close. So, I figured putting up the entire script would be helpful in trying to figure this out.

Thank you so much…
Babs

Well…
problem 1
My assumption about that item being a script property was wrong. It looks like it’s an option with a command of InDesign or Quark. I can’t tell, I have neither.
Search for it in their AppleScript dictionaries.

problem 2
I need some time to comb through the script to see what gets passed around here.
The subroutine replaces the extension, as far as I can tell.
When the script does not compile there should be some message. What is it?

problem 3
I asked whether you are still using the same Quark version. Just a shot in the dark, but 10 minutes later I saw a fresh post in this forum about differences between Quark 7 and Quark 8. Did you upgrade Quark?

The «class SPRS» suggests that something is missing in the Quark installation. AppleScript can’t find the correct term for that command, so it displays the raw code.

To be sure: the InDesign part works flawlessly?

hello!

Problem 1:

I have looked and found that suppress statement, but have not been successful wherever I put it. I’ll keep trying different places.

Problem 2:
I fixed this by removing these 2 lines: I know it’s not the right way, but it worked.

 delay 1
               keystroke tempname

Problem 3:
Yes I saw that post but we are still working on 7.
I did add a tell statement and got it as far as asking at least to close the file, but I still have to answer the dialog. This is what I added:

tell application "QuarkXPress"
				close every window saving no
			end tell

I need to put another keystroke in I think…I will work on that…

So, I am getting closer, but not here yet…
thanks!!!
babs

Great!
Progress!

That ‘suppress’ statement; I don’t think this is an actual command. Problably something like “Close window saving no”, that is, an addition to the actual command.

When you look at ‘display dialog’ in Standard Additions’ you’ll see 8 (ish) additional terms, like “hidden answer boolean”. This “suppress warnings” item is of a similar kind, I believe.

The entire command would be along the lines of: “do this, but don’t tell me what might go wrong”
What is the “do this” part?? (sticking it hither & yon will keep you busy for a while :))

Problem 3:

tell application "QuarkXPress"
               close every window saving no
           end tell

Open a few Quark documents. Put those 3 lines into a script window, and run.
Play around with the command. Try “properties of front window”, maybe the answer will show where to go.

A window cannot be saved, I guess the proper class is “document”

Hello everyone…!

More progress!

Yes Stefan!!! replacing the word “window” with “document” worked! yay!

tell application "QuarkXPress"
               close every document saving no
           end tell

I just have to figure out the suppress warning issue and I am home free on this one…

Thanks to you both…I will keep plugging away at that one…I have to get it in the right place at some point? :wink:

thanks!
babs

Hello,
Ok-I have added the line “Suppress All Warnings true”
everywhere in this script, but I can’t get it to compile.
I have even tried to put it in a tell block.

I then tried this:

try
						if exists button "List Pictures" of window 1 then
							click button "Continue" of window 1
						end if
					end try

To follow suit of the list profile button ignore that was in the script, but it didn’t work either…

Any other thoughts out there?
thanks!
babs

You said you found it in some application’s AppleScript dictionary.
Which one?

Paste the entire command from the dict in a post, and we’ll figure it out.

I really think that that clause is NOT a command:
“tell application “someapp” to suppress all warnings true” does not make sense.

Hello,

Okay-it says it’s property and here is everything in that open option in the dictionary:

open‚v : Open the specified object(s)
open specifier : list of objects to open
[use doc prefs yes/no/ask] : use document or application preferences
[remap fonts no/ask] : remap document fonts which don’t exist in the current system
[do auto picture import yes/no/ask] : whether or not to re-import any missing pictures
[reflow boolean] : “with reflow” will update the flow version of the document
[Suppress All Warnings boolean] : Suppress all the warnings. All other open options will be ignored used with this preference

thanks!!!
babs

Not “property”, I believe…
The comment for clause “reflow” shows the syntax you can use (one of several forms, actually).

HI,
Yes, I actually tried that syntax in a few places writing it like this:

with Suppress All Warnings true

but nothing stopped it.

I am now more interested in the area that says

 try
                       if exists button "List Profiles" of window 1 then
                           click button "Continue" of window 1
                       end if
                   end try

I tried adding this code and changing “List Profiles” to “List Pictures” in hopes that since that is bypassing the profile warning, it would bypass the picture warning too? But it didn’t work, unless I need something other than List Pictures?

still trying here :wink:
thanks!
babs

That clause goes with the open command only.

These are acceptable forms (but not every app will possibly accept every form):

open someFile with Suppress All Warnings
open someFile Suppress All Warnings yes
open someFile Suppress All Warnings 1
open someFile Suppress All Warnings true

And, obviously, the inverse when you want to see warnings:
without/no/0/false

I cannot help you with the GUI scripting bit, as I do not have the apps involved.

Hello!

Ok- I got it figured out…Probably not the prettiest, but it works…

I repeated the same code that must have been ignoring the list profile or font message:

try
						if exists button "OK" of window 1 then
							click button "OK" of window 1
						end if
					end try
					--added this same try again
					try
						if exists button "OK" of window 1 then
							click button "OK" of window 1
						end if
					end try

…and it worked :wink:
OK-this one is done!!!
thanks for all the help!!!

babs