InDesign CS4: Selecting a preceeding Space character

I am trying to run through a document that has some XML tagged text. I am then trying to find any “space” characters that are the 1st character of said paragraphs. In my script, the test to find character “x” works. But it is not working on trying to select and test for a space character.

What am I doing wrong? Do I have to search for a space using its ASCII id equivalent?

Any help would be greatly appreciated.

Thanks in advance,
-Jeff

tell application "Adobe InDesign CS4"
	activate
	set thecharList to {"x", " "}
	tell active document
		repeat with i from 1 to count of stories
			repeat with iPar from 1 to count of paragraphs in story i
				set theLabel to associated XML elements of word 1 of story i
				if theLabel is equal to {} then
					exit repeat
				end if
				if character 1 of word 1 of paragraph iPar of story i is in thecharList then
					set selection to character 1 of word 1 of paragraph iPar of story i
					display dialog "I do"
				end if
			end repeat
		end repeat
	end tell
end tell

A space is not a word or part of a word so you would need to test the first character of the paragraph not the first word.

Thank you Jerome. That was the reason! I also needed to test for the second character, since the first was the tag bracket. This seems to do the trick. Thank you once again.

-Jeff

tell application "Adobe InDesign CS4"
	activate
	set thecharList to {" "}
	tell active document
		repeat with i from 1 to count of stories
			repeat with iPar from 1 to count of paragraphs in story i
				set theLabel to associated XML elements of word 1 of story i
				if theLabel is equal to {} then
					exit repeat
				end if
				try
					if character 2 of paragraph iPar of story i is in thecharList then
						display dialog "I do"
						set selection to character 2 of paragraph iPar of story i
					end if
				end try
			end repeat
		end repeat
	end tell
end tell