Indesign Find paragraph based on character position

I am trying to convert a QuarkXPress script into an Indesign CS2 script, but I’m not having much luck.

I have a QuarkXPress 6.5 script that does the following:
– finds a specific character in a text box
– gets the first character of the paragraph containing this character

This is the sample text that I’ve been using for this script.

This is a sample list
1 Marketing
2 Shipping
3 +placeholder
4 Legal

Here’s the QuarkXPress script…

tell application "QuarkXPress"
	tell front document
		tell text box 1
			set astPosition to index of (every character whose it is "+")
			set paraPosition to (index of paragraph 1 whose it contains character astPosition)
			set theChar to character 1 of paragraph paraPosition
		end tell
	end tell
end tell

And the Indesign version that isn’t working…

tell application "Adobe InDesign CS2"
	tell front document
		tell text frame 1
			set astPosition to index of (every character whose it is "+")
			set paraPosition to (index of paragraph 1 whose it contains character astPosition)
			set theChar to character 1 of paragraph paraPosition
		end tell
	end tell
end tell

Any help would be greatly appreciated!

Thanks,

Jeff

Well, your code so far isn’t showing much of what you want to achieve with this, but the following should work:

tell application "Adobe InDesign CS2"
	tell front document
		set TheParagraphs to object reference of every paragraph of text frame 1 whose contents contains "+"
		set theChar to first character of item 1 of TheParagraphs
	end tell
end tell

This will give you a list of object references for the paragraphs that contain the “+” symbol as well as the first character’s contents of the first item in that list. To go any further I would need to know more about what you are trying to achieve.

Thanks… that makes sense. I haven’t used object reference in my scripting much. Looks like I should. That does the trick.

As far as what I want to achieve with this… I’m compiling a list of which number the placeholder text appears next to. Similar text to my sample text repeats multiple times throughout a longer document. I have the script repeating through each text box and looking for specific information. The plus sign marks the correct answer.

Thanks again!

Jeff