--##########################################
--This AppleScript is used by GrabbyWindow for simulating the drag to Quark Xpress 3.32 - 5.0b
--Dragging Text only
--You can change the parameters for cascading, the bounds and position of the new box, 
--and the accepted filetypes, if you use Xtensions for additional ones
--You should not change the return values 
--and you should not change anything at all, if you dont know what you are doing!!
--End If Software 2002
--
--Release 1  -  01.05.2002
--##########################################
--top position for the first box

set err to "7"
property X : 10
property Y : 10
--x+y for the first box
property W : 100
property H : 100
--cascading
property Zunahme : 5
global gtext

set gtext to "$$gText$$"




set err to "5"

try
	--timeout, if quark is busy
	with timeout of 5 seconds
	
		tell application "$$QuarkXPress Passport$$"
		activate
			set err to "9"
			--if no doc is open, create a new one
			set dnum to number of documents
			if dnum < 1 then
				try
					make document at beginning
				on error errtext
					return errtext
				end try
			end if
			
			
				--text
				try
				    --if a box is selected, paste the text into it
				 if current box of document 1 is not null then
			
					set the clipboard to gtext
					paste
					
				else
				  
					--This will cause an error, so....    
					tell current box of document 1
						set story 1 to gtext
					end tell
				end if
				on error 
				  
					tell current page of document 1
						try
							make text box at beginning with properties {bounds:{(Y as string) & " mm", (X as string) & " mm", (H as string) & " mm", (W as string) & " mm"}}
							tell text box 1
								set story 1 to gtext
							end tell
						on error errtext
							return errtext
						end try
					end tell
					
				end try
	
		    do updates
		end tell
	end timeout
on error errtext
	return errtext
end try
return err

