Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more