Highlighted

JavaScript functionalities for plugin development

Explorer ,
May 20, 2020

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

Nithu
TOPICS
How to, Scripting, SDK

Views

755

Likes

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

JavaScript functionalities for plugin development

Explorer ,
May 20, 2020

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

Nithu
TOPICS
How to, Scripting, SDK

Views

756

Likes

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
May 20, 2020 0
Adobe Community Professional ,
May 20, 2020

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

Likes

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
Reply
Loading...
May 20, 2020 1
Adobe Community Professional ,
May 21, 2020

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

Likes

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
Reply
Loading...
May 21, 2020 0
Explorer ,
May 21, 2020

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();

Nithu

Likes

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
Reply
Loading...
May 21, 2020 0
BarlaeDC LATEST
Adobe Community Professional ,
May 22, 2020

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

Likes

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
Reply
Loading...
May 22, 2020 0