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

Unterminated String constant

Guest
Sep 26, 2012 Sep 26, 2012

Hi All

I am writing a JS script and call it using doScript() method.

CString  script,cStr;

cStr contain some text like :

"I am new scrpit developer.

I am not know how develop indesign script?

but forums help me to develop my script."

Now  add this cStr in script like this :

script="#target indesign";

script+="\n";

script+="var myDocument = app.documents.add();\n";

script+="var myTextFrame = myDocument.pages.item(0).textFrames.add();\n";

script+="myTextFrame.geometricBounds = [\"5p\", \"5p\", \"80p\", \"80p\"];\n";

script+="myTextFrame.contents =\"";

script+=cStr;

script+="\";";

Now my Final Script in ExtendScript Toolkit is

#target indesign

var myDocument = app.documents.add();

var myTextFrame = myDocument.pages.item(0).textFrames.add();

myTextFrame.geometricBounds = ["5p", "5p", "80p", "80p"];

myTextFrame.contents ="I am new scrpit developer.

I am not know how develop indesign script?

but forums help me to develop my script.";

It give error Unterminated String Constant

This is because whole text is not in single line.When i write this text in single line it run sucessfully.

How pass this type of string in Script that script run sucessfully.

Thanks

TOPICS
Scripting
3.1K
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
Contributor ,
Sep 26, 2012 Sep 26, 2012

But it's working fine for me.

Try below:

var cStr = "I am new scrpit developer.I am not know how develop indesign script? but forums help me to develop my script"
script="#target indesign";
script+="\n";
script+="var myDocument = app.documents.add();\n";
script+="var myTextFrame = myDocument.pages.item(0).textFrames.add();\n";
script+="myTextFrame.geometricBounds = [\"5p\", \"5p\", \"10p\", \"10p\"];\n";
script+="myTextFrame.contents =\"";
script+=cStr;
script+="\";";
app.doScript(script, ScriptLanguage.javascript);
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
Enthusiast ,
Sep 26, 2012 Sep 26, 2012

hi,

you've got to mask the linebreaks in the cStr. -> \\n or \\r


var cStr = "I am new scrpit developer.\\rI am not know how develop indesign script? \\nbut forums help me to develop my script"

But this also depends to the way you create the string, so there may be another appoach ...

Hans-Gerd Claßen

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
Guest
Sep 27, 2012 Sep 27, 2012
LATEST

Thanks for Reply

I know the Problem,  I already told you in my above post

This is because whole text is not in single line.When i write this text in single line it run sucessfully.

Problem is that, I am getting CString cStr text from another file and I want to write as it as i get it in cStr.  I do not want to change any thing in cStr  text.

Is it possible  without changing in the text to write it?

Thanks.

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