Skip to main content
danielsian.com
Inspiring
December 15, 2018
Answered

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

  • December 15, 2018
  • 2 replies
  • 855 views

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"

This topic has been closed for replies.
Correct answer Kukurykus

dlgValues.edittext = "'string'"

2 replies

Kukurykus
KukurykusCorrect answer
Legend
December 16, 2018

dlgValues.edittext = "'string'"

danielsian.com
Inspiring
December 16, 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();