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

How to properly use a variable in a resource string in extendscript

Explorer ,
Dec 15, 2018 Dec 15, 2018

I have the following code to build a UI in ExtendScript:

var dlgValues = new Object();

dlgValues.edittext = "string";

var dlg = "dialog {text: 'Test', alignChildren: 'fill', \

        panel: Panel {orientation: 'column', \

            group: Group {orientation: 'row', \

                et: EditText {text: "+ dlgValues.edittext +", characters: 40} \

            } \

        }\

         \

    }";

var win = new Window(dlg);

win.show();

I'm trying to use a variable dlgValues to input a value in a resource string UI but it works only if the input are numbers.

For example,

dlgValues.edittext = "string";

returns "NaN" in the EditText box instead of "string".

If it is a number, like

dlgValues.edittext = "3";

everything works well.

My question is: How can I use a variable to input string values in an EditText?

I'm not considering to access the text box using: win.panel.group.et.text = "string"

TOPICS
Actions and scripting
861
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

LEGEND , Dec 15, 2018 Dec 15, 2018

dlgValues.edittext = "'string'"

Translate
Adobe
Explorer ,
Dec 15, 2018 Dec 15, 2018

I found the answer by myself, I hope this is useful for someone struggling to find documentation about resource string.

Inside the resource script the variable must be surrounded by apostrophes in order to work with strings:

var dlgValues = new Object();

dlgValues.edittext = "string";

var dlg = "dialog {text: 'Test', alignChildren: 'fill', \

        panel: Panel {orientation: 'column', \

            group: Group {orientation: 'row', \

                et: EditText {text: '"+ dlgValues.edittext +"', characters: 40} \

            } \

        }\

         \

    }";

var win = new Window(dlg);

win.show();

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
LEGEND ,
Dec 15, 2018 Dec 15, 2018
LATEST

dlgValues.edittext = "'string'"

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