LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Time Input for Numeric Box

I have a numeric input box for my UIR panel, called TestLength in seconds. I want to add both a hour input and minutes input. Right now, i am thinking of just adding three seperate numeric input boxes, hour, minutes, and seconds. And then in code, put them together in a variable total_seconds. So like, total_seconds = (hour_input*60*60) + (min_input*60)+ sec_input;

 

I was wondering if there is an easier way to do this, or if this is the best approach.

0 Kudos
Message 1 of 3
(4,059 Views)

I see three possibilities:

 

  1. One numeric input for seconds (so one hour would have to be entered as 3600)
  2. One numeric input for hours and two ring controls for minutes and seconds, alternatively three numeric inputs, the values will have to be converted to seconds in your code as you mentioned
  3. A string control which allows entering digits and two colons; however, handling the input requires some effort, you may have a look at the source code of the custom control IPctrl.c

 

 

0 Kudos
Message 2 of 3
(4,042 Views)

I normally let the user input the desired time value in a string control and post-process the text entered extracting the corresponding value. I developed a function for that which I have now published for all who can be interested: you can find it here.

The function accepts strings like "2h 15m", "2:15:00", "2.15.0", "8100s" and "8100" returning 8100 seconds in all cases.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 3 of 3
(4,034 Views)