Quark - Stop if image 1 is true

I am trying to have Quark place an image in a picture box. If it can not I have it run through a loop to add “.eps”, “.tif”, “.pdf” and try each of those.

Here’s my problem. If Quark does place it with “.eps” it still tries the others in the list and errors. I need it to stop if it is successful and to delete the picture box if it is not.

Here’s what I have so far:

set fileTypeList to (".eps", ".tif", ".pdf")
tell picture box 1
						set k to 1
						try
							--set image 1 to (hiresFileNamePath & theFile) as alias
							set image 1 to ("Macintosh HD:Desktop Folder:Magvol_1:Current:REP200407:Display Ad:Hi Res:" & theFile)
							set bounds of image 1 to exact fit
							set name to theFile
						on error
							set flag to false
							repeat with f from 1 to count of items of fileTypeList
								--set image 1 to (hiresFileNamePath & theFile & ftype) as alias
								set ftype to item f of fileTypeList
								set image 1 to ("Macintosh HD:Desktop Folder:Magvol_1:Current:REP200407:Display Ad:Hi Res:" & theFile & ftype)
								set bounds of image 1 to exact fit
								set name to theFile
								if image 1 is true then
									exit repeat
								end if
								
							end repeat
							
						end try
						
						
						-->REPLACE THIS WITH THE TELL PICT BOX DELETE
						--end tell
					end tell

I tried it with adding 1 to each loop but couldn’t figure out what to do with it?

Any ideas on what I am doing wrong would be great!

Thank you all,

Steven.

Ignore the first post! I think I cleaned it up a bit but it still will not work. This logic would work better for what I need.

  1. Place an image
  2. If that filename isn’t there try the others with an extension
  3. Place the image manually
  4. If the image just isn’t there delete the picture box.

MY Question is this: Why won’t the “then exit repeat” work?

try
						tell picture box 1
							try
								--> THIS WOULD ALLOW THE PLACEMENT OF AN IMAGE WITH NO EXTENSION FIRST
								--set image 1 to (hiresFilePath & theFile) as text
								set image 1 to ("Macintosh HD:Desktop Folder:Magvol_1:Current:REP200407:Display Ad:Hi Res:" & theFile)
								set bounds of image 1 to exact fit
								set name to theFile
								--> THIS WOULD ALLOW THE PLACEMENT OF AN IMAGE AFTER REMOVING EXTENSION  !NOT WORKING
							on error
								repeat with i from 1 to count of items of fileTypeList
									set ftype to (item i of fileTypeList)
									set theFile to (theFile & ftype)
									set image 1 to ("Macintosh HD:Desktop Folder:Magvol_1:Current:REP200407:Display Ad:Hi Res:" & theFile)
									set bounds of image 1 to exact fit
									set name to theFile
									if image 1 = true then exit repeat
								end repeat
								
								if image 1 = false then
									set usethisFile to (choose file with prompt "Choose image " & theFile)
									set image 1 to usethisFile
									set bounds of image 1 to exact fit
									set name to theFile
								end if
							end try
						end tell
					on error
						tell picture box theFile
							delete
						end tell
					end try

Why won’t this code do what the four things I need it to do?

Please help.

Thank you,

Steven.