Counting and sorting items in a loop Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
euras
Posts: 429
Joined: 05 Nov 2015, 12:56

Counting and sorting items in a loop

16 Nov 2017, 09:32

Let's say there is many blocks the code should read and then sort the things from the block, move to another block, sort the things again and add the results to the previous results and move on.
In this case I need to gather information how many tasks come due each day. So I separate each day from the list. But how to count how many results there was in the block, save this information to the next block, then do it again and add it to the results?

Code: Select all

block =
(
20 10 2017 ; in this case there will be 5 times 20 10 2017
20 10 2017 
14 11 2017 
20 10 2017 
20 10 2017 
24 10 2017 
20 10 2017 
21 10 2017         
21 10 2017 ; 5 times 21 10 207       
21 10 2017        
21 10 2017      
23 10 2017       
21 10 2017 
23 10 2017  
21 10 2017
)
list =
count = 0
loop, parse, block, `n, `r
{
	line := A_LoopField
	IfNotInString, list, %line%
		list .= llbend "count: " count "`n"
}
MsgBox %list%
User avatar
AlphaBravo
Posts: 586
Joined: 29 Sep 2013, 22:59

Re: Counting and sorting items in a loop  Topic is solved

16 Nov 2017, 11:48

Code: Select all

block =
(
20 10 2017
20 10 2017 
14 11 2017 
20 10 2017 
20 10 2017 
24 10 2017 
20 10 2017 
21 10 2017         
21 10 2017
21 10 2017        
21 10 2017      
23 10 2017       
21 10 2017 
23 10 2017  
21 10 2017
)

oBlock := []

loop, parse, block, `n, `r
	oBlock[A_LoopField] := oBlock[A_LoopField] ? oBlock[A_LoopField] + 1 : 1

for day, frequency in oBlock
	res .= day " count: " frequency "`n"
MsgBox % res
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Lamron750, septrinus and 227 guests