Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

removing the last character from a string

New Here ,
Feb 21, 2008 Feb 21, 2008
I try to move a paragraph from one textFrame to another.
my code is: myParagraph.move(LocationOptions.before,myTextFrame.insertionPoints.item(-1));
the problem is that the end of paragraph sign moves together with the paragraph.
i think that i have to write:
myString=myParagraph - the last character of the paragraph;
myString.move(LocationOptions.before,myTextFrame.insertionPoints.item(-1));
how do you write the first line in js?
TOPICS
Scripting
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 21, 2008 Feb 21, 2008
myParagraph.texts.itemByRange(myParagraph.characters[0],myParagraph.characters[-2]).move()

But this will error if the paragraph is empty.

Dave
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 21, 2008 Feb 21, 2008
thanks Dave, this idea leaves the enter in its place. is there a way that the enter will vanish?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 21, 2008 Feb 21, 2008
Just move the whole paragraph and insert this:

if(myTextFrame.characters[-1].contents = "\r"){myTextFrame.character[-1].remove()}

This assumes you didn't cause your text frame to be overset...

Harbs
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 21, 2008 Feb 21, 2008
there is not a better way than to find /r/r in the parentStory of the textFrame and to change it to /r?
(i have to do it by the script because i have to apply fitContentToFrame and to put it in a specific location on the page)
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 21, 2008 Feb 21, 2008
LATEST
harbs, thanks it is brilliant.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines