I am failing to see the way to get the index or object reference of the first character after a selected text range in InDesign CS4. Can anybody help me out?
My primary goal is to simply determine if the next character after a selected range of text is a period. In other words, the end-user forgot to select a trailing period.
tell application "Adobe InDesign CS4"
activate
set mySel to selection
set selText to object reference of selection
set myChar to (object reference of (last character of selText))
--Detect if next character after myChar is a "."
--If so, include that trailing "." in the new selection
end tell
tell application "Adobe InDesign CC 2014"
set theSelection to parent story of item 1 of selection
set theNextCharacter to character ((index of (theSelection)) + (length of theSelection) - 1) of (theSelection)
end tell
TecNix,
What you provided is excellent! I modified your snippet slightly. What I have below does detect the non-selected period.
Can you possibly help me concatenate the new selection?
For example:
“This text in quotes was selected”. <–The period was not selected.
I am having difficulty including the trailing period so it becomes part of the new selection:
“This text in quotes was selected.” <–This is what I want the newly selected text to be.
My present code is not working, but it is close. The new selection being applied is moving the selection one point over and adding an additional period. I must need to get the object reference of the old selection and then the trailing period and then have InDesign select both, but that is where I struggle.
tell application "Adobe InDesign CS4"
activate
set selText to object reference of selection
set theSelection to parent story of item 1 of selection
set theNextCharacter to character ((index of (selText)) + (length of selText)) of (theSelection)
if theNextCharacter is equal to "." then
--The below part is not correct
set contents of selection to (selText & theNextCharacter)
end if
end tell
tell application "Adobe InDesign CC 2014"
activate
set selText to object reference of selection
set theSelection to parent story of item 1 of selection
set theNextCharacter to character ((index of (selText)) + (length of selText)) of (theSelection)
if theNextCharacter is equal to "." then
select text from character (index of (selText)) to character ((index of (selText)) + (length of selText)) of theSelection
end if
end tell