Due to increasing spam attacks, forum registrations are currently paused to keep our community safe and spam-free. Come hang out and stay connected with us on the SimHub Discord: https://discord.com/invite/nBBMuX7!

Catch you on Discord — and thanks for understanding!
Format variable in ...
 
Notifications
Clear all

Format variable in Javascript - Raw result

1 Posts
2 Users
1 Reactions
2,041 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: