Format variable in ...
 
Notifications
Clear all

Format variable in Javascript - Raw result

1 Posts
2 Users
1 Reactions
1,700 Views
(@matses_51)
New Member
Joined: 3 years ago
Posts: 1
Topic starter  

Hi,

A pretty newb question I guess.

Have done some simple Ncal script previously, but have recently switched to Java.

How do I format a variable to a certain number of decimals without using the "Result format:"?

DecimalFormat and String.Format does not seem to be an option?

 

 var Time_Sec = $prop('GarySwallowDataPlugin.Leaderboard.Position01.BestLap');
var Time_Min;
var Laptime;

//Format df = new DecimalFormat("0.00");
//DecimalFormat df = new DecimalFormat("#.###");

if (Time_Sec >= 60)
{
    Time_Min="01";
    Time_Sec=Time_Sec-60;
    //format(Time_Sec,"%3f");
    Laptime = Time_Min + ":"+ (Time_Sec);
}

else if (Time_Sec >= 120)
{
    Time_Min="02";
    Time_Sec=Time_Sec-120;
    Laptime = Time_Min + ":"+ (Time_Sec);
}
return Time_Sec;


   
Montesky reacted
Quote
Share: