How do you convert a list (eg "1,2,3,4") into an array?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Diablo Sauce
Posts: 57
Joined: 20 Sep 2019, 12:54

How do you convert a list (eg "1,2,3,4") into an array?

26 Nov 2019, 14:27

My list is just a variable, like:

x=1,2,3,4,99,33

Thank you.
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Re: How do you convert a list (eg "1,2,3,4") into an array?

26 Nov 2019, 14:30

strSplit

Code: Select all

x:="1,2,3,4,99,33"
array:=strSplit(x,",")
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
User avatar
Chunjee
Posts: 1417
Joined: 18 Apr 2014, 19:05
Contact:

Re: How do you convert a list (eg "1,2,3,4") into an array?

26 Nov 2019, 14:44

"," is the default separator for https://biga-ahk.github.io/biga.ahk/#/?id=split

Code: Select all

A := new biga()
x := "1,2,3,4,99,33"

Array := A.split(x)
; => [1, 2, 3, 4, 99, 33]
String := A.join(Array)
; => "1,2,3,4,99,33"
ExitApp
you can also .join and array back into a string as demonstrated above.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: LepG, OrangeCat and 256 guests