Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

186
Vistas
ScriptUI - Integer number in slider percentage

I have a script that shows a dialog window with a slider bar, next to a static text.

The text shows the percentage of the slider bar (0 to 100).

The problem is that the percentage is shown in decimals, while I would need it to show them in integers, as the next part of the code takes the number from the text and I don't need decimals.

The code is :

    var Dial = new Window ("dialog");
    Dial.alignChildren = ["right","center"];
    var Group1 = Dial.add ("group");
    var Slide = Group1.add ("slider");
    Slide.minvalue = 0;
    Slide.maxvalue = 100;
    Slide.value = 50;
    Slide.preferredSize.width = 300;
    Slide.onChanging = function () {
        Label.text = Slide.value;
        }
    var Label = Group1.add ("statictext");
    Label.preferredSize.width = 30;
    Label.text = Slide.value;
    var Button1 = Dial.add ("button");
    Button1.text = "OK";
    Button1.onClick = function () {
        Dial.close()
        }
    Dial.show()

Someone has any idea how to do it?

I've tried with Math.round() on Label.text and on Slide.value, but I don't know if I can't use it correctly or if it's not the right code for this case.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I'm sure the line like this is the absolute correct way to get the round numbers in this case:

Label.text = Math.round(Slide.value);

If somewhere down-river you will need a string you can get the string via var myString = Label.text.toString(); or even var myString = '' + Label.text;. But usually JavaScript/Extendscript doesn't care either the value is a number or a string. It deals with them indiscriminately.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda