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

how using script variable in c#?

Community Beginner ,
Mar 02, 2018 Mar 02, 2018

i want  script variable To assign variable in c#. in this code i want variable x in script To assign lable1.text .:

            string copy = string.Format(@"

var textFrame = app.selection[0]; 

//alert( textFrame.texts[0].contents );

x=textFrame.texts[0].contents ;    -----> i want use this variable in c# .

alert(x);

");

           

            InDesign.Application InDesignApp = (InDesign.Application)Activator.CreateInstance(Type.GetTypeFromProgID("InDesign.Application"));

            InDesignApp.Activate();

            InDesignApp.DoScript(copy, InDesign.idScriptLanguage.idJavascript);

  pleas help me .

TOPICS
Scripting
1.5K
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

correct answers 1 Correct answer

Enthusiast , Mar 06, 2018 Mar 06, 2018

Sorry for the typo,

replace the first line with : app.scriptArgs.setValue("x", textFrame.texts[0].contents);

Translate
Enthusiast ,
Mar 02, 2018 Mar 02, 2018

Try this,

In js,

     app.scriptArgs.setValue("x", "textFrame.texts[0].contents");

In c#

     Console.WriteLine(InDesignApp.ScriptArgs.GetValue("x"));

Regards,

Chinna

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
Community Beginner ,
Mar 03, 2018 Mar 03, 2018

this is printing "textFrame.texts[0].contents". !!!!!

i want print content of "textFrame.texts[0].contents".

pleas help me .

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
People's Champ ,
Mar 05, 2018 Mar 05, 2018

It's just a minor typo Chinnadk​ made when he tried to HELP you. At least, you may be grateful.

I could help you fix that typo but I will choose to let you deal with it.

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
Community Beginner ,
Mar 05, 2018 Mar 05, 2018

pleas help me .

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 ,
Mar 06, 2018 Mar 06, 2018
LATEST

Sorry for the typo,

replace the first line with : app.scriptArgs.setValue("x", textFrame.texts[0].contents);

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