Ini get max numbers Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
HIAC
Posts: 111
Joined: 11 Oct 2017, 17:59
Location: Republic of Serbia

Ini get max numbers

04 Feb 2018, 20:10

[Test]
1=1
87=0
7=5
13=7
43=10
39=30
46=15
45=75

I want to get 7,43,39,46,45 (in different variables, like 7 be VAR1,43 VAR2) because these six numbers hold the largest key value

Help? :)
User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: Ini get max numbers  Topic is solved

04 Feb 2018, 20:47

This puts them in an array called Ordered. You could assign them to individual variables if you would like. By the way, you left 13 out of your expected results list.

Code: Select all

IniRead, SectionText, test.ini, Test
Numbers := {}
Loop, Parse, SectionText, `n
{
	StringSplit, Element, A_LoopField, =
	Numbers[Element2] := Element1
}
For, Key, Value in Numbers
	NumList .= Key "|"
Sort, NumList, N R D|
Ordered := StrSplit(NumList, "|")

; Results are in the array named Ordered.  The following is just to output the list in a single MsgBox:

Loop, 6
	TextOut .= Numbers[Ordered[A_Index]] ","
StringTrimRight, TextOut, TextOut, 1
MsgBox, %TextOut%
HIAC
Posts: 111
Joined: 11 Oct 2017, 17:59
Location: Republic of Serbia

Re: Ini get max numbers

04 Feb 2018, 21:02

Thanks a lot, working perfectly! :)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, DiegoSouto, mikeyww, Rohwedder, Sniperman and 393 guests