1 person found this helpful
If you try that, you'll find that the answer is "Yes".
indentHereTab works, too.
That should work (although you'd want the == operator if your are testing for its existence...)
Peter got there first...
I was just returning to say I figured it out but why does the Object Reference show the values all caps and with underscores SpecialCharacters.COLUMN_BREAK, instead of what it is, SpecialCharacters.columnBreak?
Should I have been looking somewhere else for that value or is there some rule i don't know about?
Thanks for your help ... did you guys happen to check out my other question about Graphics from yesterday?
Is there another way to reference the value of SpecialCharacters?
When I do the same thing for paragraphSymbol it doesn't recognize it.It is working for other special characters though.
When I loop through the characters and send out an alert to see what is being read byt the script, when it gets to the end of the paragraph it spits out a "blank" for the contents and actually does a hard return and give me a false when I'm expecting a true?
alert(myCharacter.contents+" " +(myCharacter.contents==SpecialCharacters.paragraphSymbol).toString());
end of paragraph is "\r".
I should have realized that .. thank you!
1 person found this helpful
1) Also, it's important to remember that any SpecialCharacters member is implemented as a pure Number:
'number' == typeof SpecialCharacters.INDENT_HERE_TAB; // true
And, in this case:
1397319796===SpecialCharacters.INDENT_HERE_TAB; // true
So there is a potential issue in just using == or != when dealing with text contents. Suppose that a textual object (story, textframe, line, word, etc.) contains the string "1397319796". Then the test:
myText.contents == SpecialCharacters.INDENT_HERE_TAB;
"1397319796" == 1397319796;
So, when you compare a contents property and a SpecialCharacters member, it's recommended to use a triple-equal sign (===), or the opposite !==, to prevent any surprising conclusion.
// Here we are sure that .contents is an actual IndentHereTab
myText.contents === SpecialCharacters.INDENT_HERE_TAB;
(Note that myText.contents, here, is a Number, not a String.)
2) Another dangerous issue is that every SpecialCharacters member is silently converted into a String object (a simple character) when myText.contents contains *other* characters. For example, if myStory contains "A" followed by an IndentHereTab, then myStory.contents returns a string of two characters:
myStory.contents === "A\x07";
because SpecialCharacters.INDENT_HERE_TAB is internally translated into U+0007.
But of course, you still have:
myStory.characters.contents === 1397319796; // true
myStory.characters.contents === "\x07"; // false
myStory.characters.contents == "\x07"; // false
While what you say is technically true, I don't think that this case is really a problem. If you are testing for a special character, the test has to be done on a single Character (or it'll fail for sure!) which can't contain more than a single character, so the test can't really fail for the reasons you say...
That's right, Harbs. My post was just a passing remark. I had so many problems with special characters when I started scripting, I just wanted to share.
Sure thing. I just wanted to clarify the point for anyone who might be reading this...
Thanks guys - all the extra info is greatly appreciated!