Skip to main content
Participant
June 1, 2013
Answered

How to pass a variable in EditText?

  • June 1, 2013
  • 1 reply
  • 1482 views

How to pass a variable in EditText?

Variable nw in edit0.

Displays: "NaN".

function dialog(nw) {

    var dlg=

        "dialog{text:'Script Interface',bounds:[100,100,570,250],"+

        "panel0:Panel{bounds:[10,10,460,140] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},"+

        "edit0:EditText{bounds:[10,55,320,75] , text:nw ,properties:{multiline:false,noecho:false,readonly:false}},"+

Sorry do not speak English.
I use a translator.

Thank you.


This topic has been closed for replies.
Correct answer Paul Riggott

With the number of all works and does not work with string.


dialog("Hope this helps");

function dialog(nw) {
    temp = nw.toString()
    alert(temp);
    var dlg=
        "dialog{text:'Script Interface',bounds:[100,100,570,250],"+
        "panel0:Panel{bounds:[10,10,460,140] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},"+
        "statictext0:StaticText{bounds:[10,10,300,30] , text:'Запись в словаре отсутствует, добавить запись?' ,properties:{scrolling:undefined,multiline:undefined}},"+
        "statictext1:StaticText{bounds:[10,30,150,50] , text:'',properties:{scrolling:undefined,multiline:undefined}},"+
        "edit0:EditText{bounds:[10,55,320,75] , text:'',properties:{multiline:false,noecho:false,readonly:false}},"+
        "button1:Button{bounds:[10,85,220,110] , text:'Добавить' },"+
        "button2:Button{bounds:[230,85,440,110] , text:'Игнорировать' }}};";
    var win= new Window(dlg,"Добавление записи");
    win.panel0.statictext1.text = nw;
    win.panel0.edit0.text = nw;
    win.center();
    var done = false;
    while (!done) {
      var x = win.show();
      if (x == 0 || x == 2) {
        win.canceled = true;
        done = true;
      } else if (x == 1) {
        done = true;
       var result = validate();
        if(result != true) {
            alert(result);
            return;
        }else
        {   
        }
      }
    }
    function validate(){
    return true;
    }
}


1 reply

Paul Riggott
Inspiring
June 1, 2013

Example...

function dialog(nw) {
var dlg=
"dialog{text:'Script Interface',bounds:[100,100,570,250],"+
"panel0:Panel{bounds:[10,10,460,140] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},"+
"edit0:EditText{bounds:[10,55,320,75] , text:"+nw+",properties:{multiline:false,noecho:false,readonly:false}}}};"
var w = new Window(dlg);
w.show();
}

dialog(21);

Participant
June 1, 2013

Does not work: "NaN"

ws is string variable.

Paul Riggott
Inspiring
June 1, 2013

Post the full code, so that we can see what's wrong.