I’m no expert, there is a very nice guide here: https://www.kahrel.plus.com/indesign/scriptui-2-0.pdf, but here are few comments:
in line 4, replace: “statictext by: “statictext”.
At this point your function createUI builds a palette but doesnt show it nor return it. You need a Window.show() somewhere. That’s the strict minimum, but there are other options (see the guide for that).
1- You can either write a line
ventana.show();
just before the end of your function. In that case, when you call createUI(thisObj), it will build then automatically show the palette.
But you will be in trouble accessing the palette data (for instance: nLayers).
2- or you can make the function return the whole palette. Instead of vendana.show() you write:
return(ventana);
In that case, to build and show the palette you write
var ventana = createUI(this);
ventana.show();
now ventana is a Window object in your script and you can access its properties. Actually since you didnt explicitely name the palette properties it’s not so easy. To read the nLayers value you’ll have to do:
var x = parseInt(vendana.children[0].children[1].text);
x = (isNaN(x) || x<1) ? 1 : x; //etc
To make things easier you can name the palette properties upon creation (the ones that you will need to access), like this:
function createUI(thisObj)
{
var ventana = (thisObj instanceof Panel) ? thisObj : new Window("palette", "mi Script", undefined, {resizeable:true});
var grupoTexto1=ventana.add("group");
grupoTexto1.add("statictext",undefined,"Nro de Layers");
var nLayers=grupoTexto1.add("edittext",undefined,"1");
nLayers.characters=4; nLayers.active=true;
ventana.nLayers = nLayers;
ventana.nLayers.onChange = function()
{
var x=parseInt(this.text);
this.text = (isNaN(x) || x<1) ? 1 : x;
}
return(ventana);
}
var pal = createUI(this);
pal.show();
var x = parseInt(pal.nLayers.text);//etc