I need script to convert seconds to minutes and seconds example 75 seconds. need to display as 1.15 for use in an led display.
Both assume your input is in Root Container.Numeric Text Field
Expression that you can bind to the LED display:
floor({Root Container.Numeric Text Field.intValue} / 60) + ({Root Container.Numeric Text Field.intValue} % 60 / 100)
Script (you’ll do something with output besides printing it…):
output = (input / 60) + float(input % 60) / 100
print output```
thank you very much Kathy! Now I am fighting with how to make my led display show : instead of .
I am new to ignition and am coming up to speed.
Once again thanks for your input!
Joe
This is a bit more involved; you’ll also need to set the LED Display to ‘Alphanumeric’ mode, and then add this to the Text property:
concat(
toInt(floor({Root Container.Numeric Text Field.intValue} / 60)),
":",
numberFormat(({Root Container.Numeric Text Field.intValue} % 60), "00")
)
I find stringFormat() a bit more handy in such situations:
stringFormat("%d:%02d",
floor({Root Container.Numeric Text Field.intValue} / 60),
{Root Container.Numeric Text Field.intValue} % 60)
I honestly forgot about stringFormat
entirely. Yeah, that’s definitely better.
thank you Paul and Phil for the assistance. Works perfectly.
Joe
Tried the expression but got an error:
Exception: Error executing expression binding on
EDIT.Root Container.LED Display.text
caused by IllegalFormatConversionException: d != java.lang.Double
modified the above expression to either of the 2 expressions below (to allow for the double returned by floor())
stringFormat("%d:%02d",
toInt(floor({Root Container.Numeric Text Field.intValue} / 60)),
{Root Container.Numeric Text Field.intValue} % 60)
or
stringFormat("%01.0f:%02d",
floor({Root Container.Numeric Text Field.intValue} / 60),
{Root Container.Numeric Text Field.intValue} % 60)