quark postscript: only first page in color

Hi,

I am trying to write a script that will place line numbers beside text. What I really want to do is add line numbers to a play, so I want a number to appear next to every 5th line of text. I found a script that places numbers on every line, but I need the script to skip any blank lines (lines that only contain a hard return).

Here is what I have so far:
set num to 5
set linect to count of lines of selection

tell selection
repeat with i from 5 to linect by 5
if line i <> “” & line i <> return & line i <> whitespace then
try
copy (num as text) to before line i of selection
set num to num +5
end try
end if
end repeat
end tell

I would love any help with this.
Thanks,
karen

Hi :slight_smile:

You wish to carry out this operation with which software?
With which version of system?

thanks…

Sorry, I always forget to add that.

I am using Quark 5.0 and Mac OS 9.2

Karen

Ok, thanks, one last question, do you want make a number before the lines or the paragraphs?

PS. I have not QXP5, but I can see if one solution exists with QXP3…

Ok, here two suggestions: :slight_smile:

  1. To work with paragraphs:
on run
	tell application "QuarkXPress™ 3.32"
		try
			activate
			if (count documents) < 1 then error "Not document open…" number 8000
			
			tell document 1
				if (selection is null) or ((class of selection) is not text) then ¬
					error "Not text selected..." number 8002
				
				set Num to 5
				set NbrPar to count every paragraph in selection
				
				tell selection
					repeat with ThePar from Num to NbrPar by Num
						set paragraph ThePar to ("" & ThePar & ". " & (paragraph ThePar))
					end repeat
				end tell
			end tell
			
			display dialog "Ok  :-)" & (beep) with icon 1
		on error MsgErr number NroErr
			if NroErr is not -128 then ¬
				display dialog "" & NroErr & " : " & MsgErr & (beep 2) with icon 0
		end try
	end tell
end run
  1. To work with the lines:
on run
	tell application "QuarkXPress™ 3.32"
		try
			activate
			if (count documents) < 1 then error "Not document open…" number 8000
			
			tell document 1
				if (selection is null) or ((class of selection) is not text) then ¬
					error "Not text selected..." number 8002
				
				set Num to 5
				set NbrLines to count every line in selection
				
				tell selection
					repeat with TheLine from Num to NbrLines by Num
						set line TheLine to ("" & TheLine & ". " & (line TheLine))
					end repeat
				end tell
			end tell
			
			display dialog "Ok  :-)" & (beep) with icon 1
		on error MsgErr number NroErr
			if NroErr is not -128 then ¬
				display dialog "" & NroErr & " : " & MsgErr & (beep 2) with icon 0
		end try
	end tell
end run

:wink:

Hi Fredo,

Thanks for your help so far. I am still having some trouble though. The script you sent works, except I cannot get it to skip blank lines. When I show invisibles in Quark, the only thing showing on the blank lines is the paragraph symbol. Do you have any suggestions to solve this problem?

Here is what my document looks like:
Person A: How are you?

Person B: I am fine.

I do not want the script to count the blank line in between the dialog.

Thanks again,
Karen

Hi Karen :slight_smile:
Here one suggestion (for paragraphs only):

on run
	tell application "QuarkXPress™ 3.32"
		try
			activate
			if (count documents) < 1 then error "Not document open…" number 8000
			
			tell document 1
				if (selection is null) or ((class of selection) is not text) then ¬
					error "Not text selected..." number 8002
				
				set NbrPar to count every paragraph in selection
				set NroParOk to 0
				
				tell selection
					repeat with NroPar from 1 to NbrPar
						set ThePar to paragraph NroPar
						if ThePar is not "" then
							set NroParOk to NroParOk + 1
							set paragraph NroPar to ("" & NroParOk & ". " & ThePar)
						end if
					end repeat
				end tell
			end tell
			
			display dialog "Ok  :-)" & (beep) with icon 1
		on error MsgErr number NroErr
			if NroErr is not -128 then ¬
				display dialog "" & NroErr & " : " & MsgErr & (beep 2) with icon 0
		end try
	end tell
end run

:wink:

Hi,

Thanks for all you’re help, your previous reply worked wonderfully. I made some changes so that it counted lines rather then paragraphs.

I have run into one small problem. It turns out the document I am working with consists of linked text boxes. So when I run the script I get error -1728 when it reaches the end of the first text box. The selected text continues onto the next text box.

Do you have any suggestions on how to handle this? I thought I could catch the error, and then rerun the script at the beginning of each text box, beginning with the next line number. But I have not been able to get this working.

Thanks again for all your help up to this point. I am doing this for a co-worker, and I think I may be in over my head.

Karen

Hi Karen :slight_smile:

I do not have absolutely any problem when I run the script on an existing text in several linked text boxes.

I think that this incompatibility comes from the version of XPress that you used.

The solution that I propose to you, it is to past the totality of the text in an independent text box, then to run the script with this text, finally, to replace the text modified in the original linked text boxes.

Please keep me informed. :wink:

PS. Sorry for my bad english… :slight_smile:

Hi all,

the following dropletscript generates a postscriptfile for every quarkdoc dropped on it. If i drop 4 full color quarkdocs on it, only the first one is in color, the last 3 are grayscale. How is this possible?


-- This droplet processes both files or folders of files dropped onto the applet 
property thepath : ""
property shortName : ""

on open these_items
		set thepath to (choose folder) as text
	repeat with i from 1 to the count of these_items
		set this_item to (item i of these_items)
		process_item(item i of these_items)
	end repeat
end open

-- this sub-routine prints the files 
on process_item(this_item)
	tell application "QuarkXPress 4.11 NL"
		activate
		open this_item
		tell document 1
			set doc_name to name
			tell print setup
				set printertype to "PD{Printdrive_2}-X-8_6"
                                     --blabla
			end tell
			set pgcount to count pages
			set pg to name of page 1
			repeat with i from 1 to pgcount
				set pg to name of page i
				set i to pg
				set PS_file_path to coerce (thepath & doc_name & pg & ".ps") to string
				show page pg
				print page i PostScript file PS_file_path
			end repeat
			close saving no
		end tell
	end tell
end process_item


I run this code in Classic on OS 10.3.2 with Quark 4.11, G5

TIA! Fuut

hmm, what’s going on here! i posted a “New Topic”, but it is posted in this thread… :? :?

gonna try again… :oops:

hmm, what’s going on here! i posted a “New Topic”, but it is posted in this thread… :? :?

gonna try again… :oops: