Copy link to clipboard
Copied
Hi all
I'm hoping someone can see the error in the code below. I cannot. This very simple script is supposed to look at the last character of every line and, if it's a space, remove underlining from the space. It worked until I added the if statement (which I had to do because without it, the script was removing the underlining from a letter that preceded an automatic hyphen). As its written now, it fails to find the spaces at the end of lines.
I'm grateful (as always) for any help. Here's the script.
Copy link to clipboard
Copied
You need to look at the character's contents property:
myLines[i].characters[-1].contents
Copy link to clipboard
Copied
Thank you so much, Brian. That was it. I have a lot of experience with VBA, but I'm still JavaScript novice. I would never have thought to add ".content" after "characters[i]." Lesson learned.
Copy link to clipboard
Copied
Glad I could help. For more details, check out the InDesign DOM: .https://www.indesignjs.de/extendscriptAPI/indesign-latest/#about.html
A Character object has many properties, not just the actual value of the string. You are calling another one of those properties with .underline
Copy link to clipboard
Copied
Got it. Now just to remember it next time I need to do something like this. It will help if I ever get Intellisence working on Visual Studio Code.