LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need Better Way to Enter Time Values

LV2013.

 

I need to let the user enter a START TIME and a DURATION.

 

I need MINUTES and SECONDS, with tenths of a second possible.

 

The START TIME is relative to the beginning of a file, not absolute time.

 

I'm using a DBL control.

 

DATA ENTRY is using an INCREMENT of 0.1, Coerced, and a MINIMUM of 00:00.0 (start time) or 00:00.1 (duration), Coerced

 

My DISPLAY FORMAT is set to (advanced) %<%M:%S%1u>t

 

At first that appears to work correctly:  

If I set it (via property node or local var) to 65.4, it shows "01:05.4".

 

If I read it via terminal, I get a value of 65.4.

 

However, what I can't do is enter "65.4" into the control via keyboard - it gets turned into 65:00.4

 

I can't even enter "1:05" into the control - it rejects that and keeps the previous value.

 

If I enter "1:05.0", it accepts that, because it fits the format, I suppose.  But it won't accept it without the decimal point.

 

I'd like for the user to be able to enter "1:05" or "65" and turn it into 65 seconds.

 

If I remove the "%1u" from the format string, I can enter "1:05" and it's OK.  But it won't show tenths of seconds, and it STILL doesn't work right if I enter "65" (It turns into 65:00).

 

How can I make it smarter?

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 1 of 5
(2,445 Views)

I have never been impressed with time formatting. What you are asking is very reasonable, but I would not be surprised that it cannot be done with the available formatting options.

 

While hoping for good news, consider using a string control and writing your own parser.

 

Lynn

0 Kudos
Message 2 of 5
(2,433 Views)

Hi Steve,

 

that's a tricky problem.

 

It starts with your increment of 0.1, which will easily lead to rounding errors. I got those once with a control allowing range 0 to 100 with increment 0.1: my users tend to use the increment/decrement buttons and wondered why they got stuck at 99.9…

 

The next problem is your use case of typing "65": of course it gets accepted as "65:00.0" as the first number in your input is assigned to the minutes part! I would start to wonder when the first number is assigned to the seconds entry…

 

My solution would involve using a string control and program all input handling on your own. You might think about a XControl…

 

Edit: I got interrupted while writing this message - but came to same conclusion as Lynn…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 5
(2,419 Views)

It starts with your increment of 0.1, which will easily lead to rounding errors

 

That's a small problem, in the context of the other misbehaviors.

 

The next problem is your use case of typing "65": of course it gets accepted as "65:00.0" as the first number in your input is assigned to the minutes part! I would start to wonder when the first number is assigned to the seconds entry…

 

It's not the first number that is assigned to the "seconds", it's the LAST.

 

If your control is set up for 1000, and you type in "12", are you surprised when it doesn't come up with "1200" ?   I bet not.

 

It looks to me like it's imposing the format on the keyboard input, as well as the formatted output.  

 

I suppose that means I could use a format like "%S:%M:%D" to enter the seconds before the minutes before the day of the month, but I don't see the value in that.

 

However, I suppose that is the reason behind it.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 4 of 5
(2,411 Views)

Yeah I shouldn't have to suggest this, but I'd say you can do this with an XControl.  Have a string interface that gets updated as the user types for checking the format.  Then have it return the relative seconds as a double.  Of course if you ever get this working the community would surely appreciate it if you shared it.  Smiley Happy

0 Kudos
Message 5 of 5
(2,396 Views)