오토핫키의 별볼일 없는 Array를 진짜 Array처럼 확장시켜주는 소스입니다
Concat(array2,array3,...,arrayX) ? ? ? ? ?- join two or more arrays
IndexOf(Item, Start := "") ? ? ? ? ? ? ? ?- searches the array for item, front to back
Join(Sep := ",") ? ? ? ? ? ? ? ? ? ? ? ? ?- joins the elements of an array into a string
LastIndexOf(Item, Start := "") ? ? ? ? ? ?- searches the array for item, back to front
Length() ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?- returns the number of elements
Pop() ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? - returns and removes last element of array
Push(item1, item2, ..., itemX) ? ? ? ? ? ?- adds new items to the end of the array
Reverse() ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? - reverses the order of the elements
Shift() ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? - returns and removes first element of array
Slice(Start, End := "") ? ? ? ? ? ? ? ? ? - returns the selected elements as a new array
Sort(Options := "") ? ? ? ? ? ? ? ? ? ? ? - sorts the items of the array
Splice(Start, HowMany, item1, ..., itemX) - adds/removes items to/from the array
Unshift(item1,item2, ..., itemX) ? ? ? ? ?- adds new items to the beginning of the array
위 명령을 추가로 사용 할 수 있습니다.
소스는 아래 링크에서 체크하시고..
아래에 예제만 붙여넣기 합니다.
출처 & 소스 :?http://www.autohotkey.com/board/topic/94602-additional-methods-for-indexed-arrays/
; Autoexecute #NoEnv #SingleInstance force #Include Array Extensions.ahk none := [] hege := ["Cecilie", "Lone"] stale := ["Emil", "Tobias", "Linus"] kai := ["Robin", "Tobias", "Walter"] Num := [5,3,7,9,1,13,999,-4] children := hege.Concat(stale, kai) MsgBox, 0, Concat Arrays Building Children, % "Children =`n" children.Join("`n") MsgBox, 0, IndexOf Tobias, % children.IndexOf("Tobias") MsgBox, 0, IndexOf Tobias with Start = 5, % children.IndexOf("Tobias", 5) MsgBox, 0, LastIndexOf Tobias, % children.LastIndexOf("Tobias") MsgBox, 0, LastIndexOf Tobias with Start = 5, % children.LastIndexOf("Tobias", 5) MsgBox, 0, LastIndexOf Tobias with Start = 5, % children.LastIndexOf("Tobias", 5) MsgBox, 0, Length of Children, % children.Length() MsgBox, 0, Pop an Element, % children.Pop() MsgBox, 0, Array After Pop, % children.Join("`n") MsgBox, 0, Push Micheal, % children.Push("Micheal").Join("`n") MsgBox, 0, Shift an Element, % children.Shift() MsgBox, 0, Array After Shift, % children.Join("`n") MsgBox, 0, Unshift George, % children.Unshift("George").Join("`n") MsgBox, 0, Slice Out Indexes 2 - 4, % children.Slice(2, 4).Join("`n") MsgBox, 0, Splice - 2 Elements Removed at Index 3 , % children.Splice(3, 2, "Sally", "Amy").Join("`n") MsgBox, 0, Splice - Sally`, Amy Added at Index 3 , % children.Join("`n") MsgBox, 0, Sort Children, % children.Sort().Join("`n") MsgBox, 0, Numerical Sort, % Num.Sort("N").Join("`n") MsgBox, 0, Reverse Children, % children.Reverse().Join("`n") return
처음에 오토핫키에서 배열을 제대로 지원 안하는걸 보고 너무 실망했어요.. 배열도 지원 안하는 언어라니..!