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

dialog window convert number

Participant ,
Sep 09, 2015 Sep 09, 2015

In the dialog screen

How do I convert a number entry

does not cause

I write

var s = Number(sAtext.text)

and

s*3

var w = new Window("dialog");

w.orientation = "row";

w.alignChildren = "left";

var sA = w.add("statictext", undefined, "A)");

var sAtext = w.add("edittext", [0, 0, 35, 20]);

sAtext.active = true;

var sB = w.add("statictext", undefined, "B)");

var sBtext = w.add("edittext", [0, 0, 35, 20]);

w.add("button", undefined, "TAMAM", {name: "ok"}).onClick = function() {

w.close(8);

};

var a = "A) "

var b = "B) "

var c = "C) "

var d = "D) "

var e = "E) "

var s = Number(sAtext.text); // ????????????????????

var k = Number(sBtext.text); // ????????????????????

var cAse = w.show();

if(cAse == 8) {

if (app.selection[0].characters.length > 0){

app.selection[0].texts[0].remove();

}

app.selection[0].texts[0].insertionPoints.item(-1).contents = a + ((s*1) + (k * 0));

app.selection[0].insertionPoints[-1].contents = SpecialCharacters.FLUSH_SPACE;

app.selection[0].texts[0].insertionPoints.item(-1).contents = b + ((s*1) + (k * 1));

app.selection[0].insertionPoints[-1].contents = SpecialCharacters.FLUSH_SPACE;

app.selection[0].texts[0].insertionPoints.item(-1).contents = c + ((s*1) + (k * 2));

app.selection[0].insertionPoints[-1].contents = SpecialCharacters.FLUSH_SPACE;

app.selection[0].texts[0].insertionPoints.item(-1).contents = d + ((s*1) + (k * 3));

app.selection[0].insertionPoints[-1].contents = SpecialCharacters.FLUSH_SPACE;

app.selection[0].texts[0].insertionPoints.item(-1).contents = e + ((s*1) + (k * 4));

}

TOPICS
Scripting
426
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 ,
Sep 09, 2015 Sep 09, 2015

Quick debug ...

var a="A) ",b="B) ",c="C) ",d="D) ",e="E) ",s,k;

//

mDialog()

//

mFunction()

//

function mDialog(){

    var w = new Window("dialog");

    w.orientation = "row";

    w.alignChildren = "left";

    var sA = w.add("statictext", undefined, "A)");

    var sAtext = w.add("edittext", [0, 0, 35, 20]);

    sAtext.active = true;

    var sB = w.add("statictext", undefined, "B)");

    var sBtext = w.add("edittext", [0, 0, 35, 20]);

    //

    var cancelButton=w.add("button", undefined, "Cancel", {name: "cancel"});

    var okButton = w.add("button", undefined, "TAMAM", {name: "ok"});

    if (w.show () == 1){

        s = Number(sAtext.text);

        k = Number(sBtext.text);

        if ((isNaN(s)) || (isNaN(k))){

            alert("Not a number");

            exit();

        }

    }else{

        exit();

    }

}

//

function mFunction(){

    if (app.selection[0].characters.length > 0){

        app.selection[0].texts[0].remove();

    }

    app.selection[0].texts[0].insertionPoints.item(-1).contents = a + ((s*1) + (k * 0));

    app.selection[0].insertionPoints[-1].contents = SpecialCharacters.FLUSH_SPACE;

    app.selection[0].texts[0].insertionPoints.item(-1).contents = b + ((s*1) + (k * 1));

    app.selection[0].insertionPoints[-1].contents = SpecialCharacters.FLUSH_SPACE;

    app.selection[0].texts[0].insertionPoints.item(-1).contents = c + ((s*1) + (k * 2));

    app.selection[0].insertionPoints[-1].contents = SpecialCharacters.FLUSH_SPACE;

    app.selection[0].texts[0].insertionPoints.item(-1).contents = d + ((s*1) + (k * 3));

    app.selection[0].insertionPoints[-1].contents = SpecialCharacters.FLUSH_SPACE;

    app.selection[0].texts[0].insertionPoints.item(-1).contents = e + ((s*1) + (k * 4));

}

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
Participant ,
Sep 09, 2015 Sep 09, 2015

mfunction into attaching why give error

if(sAtext.text.length == 1 && sBtext.text.length == 0)

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 ,
Sep 09, 2015 Sep 09, 2015
LATEST

Why testing sAtext.text.length and sBtext.text.length ?


You can test numeric value of a & s ...

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