Copy link to clipboard
Copied
Hi,
Can someone give me the explanation of importScript.Append(); functionalities in C++ while developing an new plugin using Javascript functionalities
Copy link to clipboard
Copied
There is no such thing as importScript defined in the C++ sdk, that i could find. So if i am correct, looking at how you have written this code statement my guess is that importScript is a user defined variable of type maybe PMString, if that is so then the question does not make sense. How are we going to explain what code you have written, this is a basic statement of appending some stuff to the value of a variable. There is nothing to explain here.
-Manan
Copy link to clipboard
Copied
Hi,
Could you post the code where you are using it including the surrounding code to give us some context?
Regards
Malcolm
Copy link to clipboard
Copied
Hi,
I'm sry that the importScript is an user defined object and while using this code in SDK but I shows an JavaScript error. Is there any bug in this code. Please guide me.
PMString importScript;
Utils<IScriptArgs>()->Set("Word Count", importScript);
importScript.Append("var wordCount = 0;");
importScript.Append("for(var i=0;i<app.activeDocument.stories.length>i;i++)");
importScript.Append("wordCount += app.activeDocument.stories[i].words.length;");
importScript.Append("app.scriptArgs.setValue(\"Word Count :\",String(wordCount ));");
PMString engineName("myengine");
PMString WordCount = Utils<IScriptArgs>()->Get("wordCount ");
int32 errorCode = Utils<IExtendScriptUtils>()->RunScriptInEngine(engineName, importScript);
Utils<IScriptArgs>()->Clear();
Copy link to clipboard
Copied
HI,
So the
Utils<IScriptArgs>()->Set("Word Count", importScript);
Line is defined as
virtual void IScriptArgs::Set ( const PMString & name,
const PMString & value
)
pure virtual
Set a scripting parameter in the current context.
Parameters
name of the parameter
value of the parameter
Therefore the importScript is just a PMString object which has a number of methods, one of which is Append, and it is defined as
void PMString::Append ( const PMString & s,
CharCounter nCharacters = kMaxInt32
)
Append the first n characters of s onto this string.
Parameters
s string to append
nCharacters number of characters in s to append
So the Append method, takes a number of characters from a second string and appends it to the string. This has nothing to do with JavaScript, this is just a standard string method.
Regards
Malcolm