Page 1 of 1

Split List into separate strings

Posted: 29 Nov 2022, 10:21
by HiSoKa
Hello,
I have this code, it works fine.

Code: Select all

List =
(
Section = 1
Section = 2
Section = 3
Section = 4
Section = 5
Section = 7
)

Loop, Parse, List, `n`r
Array := StrSplit(List, "`n")
MsgBox, % Array.5

Esc::ExitApp
But when I change the number 5 in line #13 and try to define it from a variable, it does not work..

Code: Select all

List =
(
Section = 1
Section = 2
Section = 3
Section = 4
Section = 5
Section = 7
)
var := 5

Loop, Parse, List, `n`r
Array := StrSplit(List, "`n")
MsgBox, % Array.var

Esc::ExitApp
Any thoughts ?

Re: Split List into separate strings  Topic is solved

Posted: 29 Nov 2022, 10:41
by sofista
Try:

Code: Select all

MsgBox, % Array[var]

Re: Split List into separate strings

Posted: 29 Nov 2022, 10:49
by HiSoKa
This is exactly what I needed, Thank you