Skip to content

Commit e10b03b

Browse files
author
Antonio
committed
Backup Combine() [before the forum goes crazy]
1 parent b83b362 commit e10b03b

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

Combine_BACKUP.ahk

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
CHANGELOG:
2+
3+
13/september/2012
4+
• Fixed output concatenation when the p_Func function returned blank
5+
6+
29/august/2012
7+
• Initial release
8+
9+
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
10+
11+
EXAMPLE + CODE:
12+
13+
; =====================================================
14+
; By Antonio (aka MasterFocus)
15+
; Timestamp: 29/AUG/2012 20:30
16+
; Licensed under GNU AGPL v3
17+
; For more information, please see:
18+
; - http://www.autohotkey.com/community/viewtopic.php?f=2&t=59511
19+
; (this temporary header will be modified later)
20+
; =====================================================
21+
22+
List =
23+
(
24+
1234
25+
a
26+
@#
27+
txk
28+
)
29+
30+
MsgBox, % Combine(List)
31+
32+
EXITAPP
33+
34+
;------------------------------------------
35+
36+
Combine(p_List,p_InputD="`n",p_InputO="`r",p_InnerD="",p_InnerO=" `t",p_OutputDin="",p_OutputDout="`n",p_Offset=0,p_Count=0,p_Func="") {
37+
If ( p_List = "" )
38+
Return
39+
l_Total := 1, l_IsFunc := IsFunc(p_Func), p_Offset := Abs(p_Offset)
40+
StringSplit, l_List, p_List, %p_InputD%, %p_InputO% ; split main list
41+
Loop, %l_List0% {
42+
l_List%A_Index%Index := 1
43+
StringSplit, l_List%A_Index%Char, l_List%A_Index%, %p_InnerD%, %p_InnerO% ; split inner lists
44+
l_Total *= l_List%A_Index%Char0
45+
}
46+
If ( p_Count > l_Total ) OR ( p_Count = 0 )
47+
p_Count := l_Total - p_Offset
48+
Loop, %l_Total% {
49+
l_MainIndex := A_Index, l_Result := ""
50+
Loop, %l_List0% {
51+
l_Divisor := l_List%A_Index%Char0
52+
Loop, % l_List0 - ( l_InnerOffset := A_Index )
53+
l_AuxIndex := A_Index+l_InnerOffset, l_Divisor *= l_List%l_AuxIndex%Char0
54+
l_AuxIndex := l_List%A_Index%Index
55+
l_Result .= p_OutputDin l_List%A_Index%Char%l_AuxIndex%
56+
57+
l_List%A_Index%Index += !Mod(l_MainIndex,l_Total/l_Divisor)
58+
If ( l_List%A_Index%Index > l_List%A_Index%Char0 )
59+
l_List%A_Index%Index := 1
60+
61+
}
62+
If ( l_MainIndex-1 < p_Offset )
63+
Continue
64+
l_Result := SubStr(l_Result,1+StrLen(p_OutputDin)), l_Result := l_IsFunc
65+
? (((l_Dummy := %p_Func%(l_Result))<>"") ? p_OutputDout l_Dummy : "")
66+
: p_OutputDout l_Result, l_Output .= l_Result
67+
If ( --p_Count <= 0 )
68+
Break
69+
}
70+
Return SubStr(l_Output,1+StrLen(p_OutputDout))
71+
}

0 commit comments

Comments
 (0)