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

Inserting text and special characters at the insertion point

New Here ,
Nov 29, 2022 Nov 29, 2022

Copy link to clipboard

Copied

I'm trying to insert some text, followed by a column break, followed by some more text at the insertion point.  I'm working in Javascript.  The following doesn't work.

 

myIP.contents = "some text" + SpecialCharacters.columnBreak + "some more text";

 

because Javascript is just ends up converting SpecialCharacters.columnBreak into a number and inserting the number into the string.  How do I get this to work?

TOPICS
How to , Scripting

Views

974

Translate

Translate

Report

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

correct answers 1 Correct answer

Guide , Nov 29, 2022 Nov 29, 2022

Hi @John Bruestle,

 

Very interesting problem.

 

  • I don't know a direct assignment solution in that particular case, because SpecialCharacters.columnBreak happens to belong to the set of special characters that have no univocal code point. Indeed, the underlying UTF16 code is U+000D (i.e. "\r") which is also assigned to other character breaks (end of para, frame break, etc.) So you cannot use sth like

 

 

myIP.contents = "some text" + "\r" + "some more text"; // won't work

 

 

Note that this is a special c

...

Votes

Translate

Translate
Explorer ,
Nov 29, 2022 Nov 29, 2022

Copy link to clipboard

Copied

Hi John,

create a helper textframe outside of the page and add the ColumnBreak with a GREP or TEXT changeTo command. Then duplicate the ColumnBreak character to where you want it in the text.

Votes

Translate

Translate

Report

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
Guide ,
Nov 29, 2022 Nov 29, 2022

Copy link to clipboard

Copied

Hi @John Bruestle,

 

Very interesting problem.

 

  • I don't know a direct assignment solution in that particular case, because SpecialCharacters.columnBreak happens to belong to the set of special characters that have no univocal code point. Indeed, the underlying UTF16 code is U+000D (i.e. "\r") which is also assigned to other character breaks (end of para, frame break, etc.) So you cannot use sth like

 

 

myIP.contents = "some text" + "\r" + "some more text"; // won't work

 

 

Note that this is a special case. Most of the time you can reduce the SpecialCharacters enum into the corresponding "\uHHHH" code. (More on ID special character codes here: https://www.indiscripts.com/post/2009/07/idcs4-special-characters)

 

  • So, in order to handle such equivocal SpecialCharacters codes, it seems necessary to explicitly send the single command someIP.contents=SpecialCharacters.columnBreak at some point. Which leads to split the insertion process like so:

 

 

// The text you want to insert as an array
// (isolating the special char enum.)
// ---
var a = ["some text", SpecialCharacters.columnBreak, "some more"];
for( var i=a.length ; i-- ; myIP.insertionPoints[0].contents=a[i] );

 

 

A bit heavy-handed, but I'm curious if our colleagues have found a better approach.

 

Best,

Marc

Votes

Translate

Translate

Report

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
People's Champ ,
Nov 29, 2022 Nov 29, 2022

Copy link to clipboard

Copied

I haven't!

Votes

Translate

Translate

Report

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
Community Expert ,
Nov 29, 2022 Nov 29, 2022

Copy link to clipboard

Copied

Disregard. I was thinking of other special chars that are replaceable. I was going to say I usually insert a unique string and then findText to replace. Either Steve or Marc's approaches probably are the only way. The other solution would be to apply a column break Keep style to the string that occurs prior to the break. 

Votes

Translate

Translate

Report

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
Community Expert ,
Nov 29, 2022 Nov 29, 2022

Copy link to clipboard

Copied

I do not know any other possibility to handle this case.

In terms of readability of would prefer a three liner without for-loop.

Votes

Translate

Translate

Report

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
Community Expert ,
Dec 01, 2022 Dec 01, 2022

Copy link to clipboard

Copied

LATEST

Hi Marc,

a different approach, yes, but not a better one:

One alternative would be to move text in, one character, the one with the special character that has to be added to a new text frame.

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Votes

Translate

Translate

Report

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