finding a colon

I’ve written an applescript that will go through an InDesign CS selection and apply styles to the various paragraphs depending on specific criteria. One criteria to apply a “Nested Paragraph Style” is to find a colon in the first line of the selected paragraph. But I can’t seem to make it work. This is the script that I’ve written: (the part I can’t get to work is the line that says “if line 1 contains “:” then…” If I substitute a specific word for the colon it will work. But right now it’s setting the style of every paragraph to “nesting” even though there aren’t any colons in the paragraph. Is there an “escape” character that I need to put before and after the colon? I’ve searched everywhere for an answer but haven’t found anything.
Thanks for whatever help you can give.

Art Joyce

tell application "InDesign CS"
	activate
	tell document 1
		set theParaStyle to paragraph style "Paragraph Body"
		set mainHead to paragraph style "Main Headings"
		set nesting to paragraph style "Nested paragraph"
		set myselection to selection
		set myParagraphs to (count of paragraphs of selection)
		repeat with x from 1 to myParagraphs
			tell paragraph x of selection
				if paragraph style is not theParaStyle then
					set applied paragraph style to theParaStyle
					if line 1 contains ": " then
						set applied paragraph style to nesting
					end if
					if (count of characters) < 30 then
						set applied paragraph style to mainHead
					end if
				end if
			end tell
		end repeat
	end tell
end tell

Model: PowerBook G4
AppleScript: 1.10.6
Browser: Safari 417.9.3
Operating System: Mac OS X (10.4)

Well, since no one seems to be able to help me with my problem, I’ve been like Edison who tried and tried till he knew what DIDN’T work. And in the process I finally put together a script that does the job. So, if this could help someone, I’ll post it here for your consumption. It may not be very sleek or refined, but it does what I need.

tell application “InDesign CS”
activate
tell document 1
–remove empty paragraphs
set theSearchString to “^p^p”
set theReplaceString to “^p”
search for theSearchString replacing with theReplaceString
–load the variables with Paragraph style names
set theParaStyle to paragraph style “Paragraph Body”
set mainHead to paragraph style “Main Headings”
set nesting to paragraph style “Nested paragraph”
–put the number of paragraphs into a variable to use for the repeat loop
set myParagraphs to (count of paragraphs of selection)
–cycle through paragraphs and set paragraph style as needed
repeat with x from 1 to myParagraphs
tell paragraph x of selection
–set the paragraph style for a normal paragraph
if paragraph style is not theParaStyle then
set applied paragraph style to theParaStyle
–set the paragraph style for the centered headings
if (count of characters) < 30 then
set applied paragraph style to mainHead
end if
end if
end tell
–set up for the nested paragraph style
set myselect to paragraph x of selection
tell paragraph x of selection
if (count of characters) > 30 then
–look for the colon which determines the character style for the nested paragraph
if “:” is in myselect then
set applied paragraph style to nesting
else
set applied paragraph style to theParaStyle
end if
end if
end tell
end repeat
end tell
end tell