Listview/ total time / sorting

Moderator: Moderator Group

Listview/ total time / sorting

Postby clatsy » Tue Feb 07, 2017 1:22 pm


I have 3 stopwatches for a competition done with variables. The format is displayed as label output 00:00,0 (min,sec,decsec).
Each competitor has a buzzer button which they hit when completed their task. The timer stops and the times are stored in a listview, example 00:43,6
So far no problem.
For the next round i want to add the times from the first round when they finsihed their second task; example 00:43,6 + 00:23,3 = 01:06,9
This should happen as soon as they hit the button. I have use excel to export times in this format and excel can add them togheter for me. The problem i have is i cant export to excel until all timers has stopped, if i do it with the button being pressed it stops the other timers running for some seconds. Storing to excel interupts the script timer used to generate the stopwatches. So im looking for other ways within the widget to add the total time instead of using excel but stll have the format of 00:00,0
I can convert the time into just a variable integer 00:43,6 -> 436 and so on and sum those values in a listview for instance. But i cant figure out how to get it back to the "time" format 00:00,0. Or if there is other options i havent thought of adding times in this format in the widget

Second is it possible to sort columns in a listview so they stick togheter? i want a top four list with each country and time. So i need the times to be sorted in the fastest but also keep track of what country it beongs to.
COUNTRY_A - 00:30,5
COUNTRY_B - 00:23,4
COUNTRY_C - 00:45,7
COUNTRY_D - 00:22,1
COUNTRY_D - 00:22,1
COUNTRY_B - 00:23,4
COUNTRY_A - 00:30,5
COUNTRY_C - 00:45,7

Appreciate any help or feddback for this.

You do not have the required permissions to view the files attached to this post.
Posts: 8
Joined: Fri Mar 16, 2012 3:50 pm
Location: Malmö

Re: Listview/ total time / sorting

Postby Yvonne Groetzschel » Wed Feb 08, 2017 1:57 pm

Hi Rob,

my colleague already wrote you three times the following mail. Maybe you get our mails as spam?

"Working with Excel would be very comfortable, but it is indeed quite slow.
Here is something I just thought up for handeling the times (adding, finding the best time):

When you run a ScriptTimer, add a variable "Timer1_Counter" counting +1 everytime, which results in a value containing the tenth of seconds duration for each heat.
At the same time you stop the ScriptTimer, you add a second command where you add this value to an array variable "Discipline_1" -> VArrayAppend,Discipline_1,Timer1_Counter
The first value in this array will always be the fastest time.

Do the same thing only for country specific times: VArrayAppend,Germany_AllTimes,Timer1_Counter
This enables you to add the times for each country.

And last but not least, you need a macro or a function that takes the tenth of seconds duration and calculates a displayable value from that and fills this value into the corresponding ListView cells.

Second issue, Text Input:

In principle, what you have seems like the easiest way for beginning.
If you don't need all values to be sent at once, but can allow some milliseconds between sending two values, you could use a setup of one Variable input node connected to one PB Text output node and alternate the value sent within a loop.
E.g. you want to send the three times of Poland of the first heat.
You would then run a for loop (1 to 3) that sets
1) The Text ID parameters to the respective PB Text Input ID with "WDNodeSetParam,NodeID,ParamID,Value"
2) the chosen variable to the value of one ListView cell with "VGetListViewCell,VarName,ID,Col,Row"
within each loop.

You would of course have to think about a reasonable ID assignment so that you can make use of the loop index.


Sorting the ListView is not possible in an easy way, you would have to build an algorithm around this problem, probably by using array variables, sorting those and running some for loops and if statements over the elements of those and fill them into the ListView afterwards. Not an easy way, but possible.

It would indeed be one of the most comfortable approaches using the absolute times in milliseconds (or tenths of seconds) in the background and when you want to display something somewhere, just put the value in the function for calculating the "00,10,54" form.

This is just a quick overview, keep on asking if something is not clear."

Best regards,
User avatar
Yvonne Groetzschel
Posts: 49
Joined: Mon Dec 01, 2014 2:10 pm

Re: Listview/ total time / sorting

Postby clatsy » Wed Feb 08, 2017 7:15 pm


Thank you Yvonne and I got answers later on from a colleague of yours.
And sorry for all the extra emails to the support. The tickets has always worked before so i wasnt sure you recived my email.
I used a different email next time.

I will try out the VarrayAppend.
Text input node i understand i will sort out.
The only thing i struggle with is how to get started with the function/macro how to "convert" the variable doing the tenth of a second (example 2340) into my time format, 00:23,4.
How can you splitt/dived up the a integer into labels and add : and , ?

Again thanks for your support, always appreciated.

Posts: 8
Joined: Fri Mar 16, 2012 3:50 pm
Location: Malmö

Re: Listview/ total time / sorting

Postby scottywalker » Thu Feb 09, 2017 9:53 pm

I would do this by having 4 variables (minutes,seconds,milliseconds,result). I would then make 5 labels. 1st label will show the variable minutes, 2nd label will show ":" 3rd label will show the variable seconds, 4th label will show "," 5th label will show the variable milliseconds. Next make a textbox. set the counter running that will change your variables then when you click stop and want to record your result you can add the text of each label into the textbox and then add the result of the textbox to your "result" variable. something like this:

Posts: 31
Joined: Thu Aug 16, 2012 12:58 pm
Location: Dubai U.A.E

Return to Widget Designer V4.7

Who is online

Users browsing this forum: No registered users and 4 guests