Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

184
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!