tempuser wrote: ↑21 Oct 2018, 04:40
Can anyone help me with changing my code to work with
any string length (defined by iNameLenght) without copy/pasting
loop, parse section (and without using functions if possible - but not necessary)?
"While", "While" everywhere:
Code: Select all
a := "abcde" ;; character's used
b := 4 ;; lenght
d:=f:=0, c:=[], e:=[], g:=[]
While !(subStr(a,a_index,1)="")
g[a_index]:=subStr(a,a_index,1)
While !(g[a_index]="")
c[a_index] := g[a_index]
While !(b=a_index) {
While !(c[d+1]="") {
d++
While !(g[a_index]="")
f++, e[f] := c[d] . g[a_index]
} d:=f:=0
While !(e[a_index]="")
c[a_index] := e[a_index]
}
While !(c[a_index-1]=""&&a_index<>1)
z .= c[a_index] . " "
Msgbox % z
/*
While !(c[a_index-1]=""&&a_index<>1)
Msgbox % c[a_index]
*/
Edit: Way more efficient code ↓.
Code: Select all
a := "0123456789" ;; character's used
b := 5 ;; lenght
Loop, % (StrLen(a), f:=[])
f[A_Index]:=SubStr(a,A_Index,1)
Loop, % (b-1, c:=[f*])
{
For b, d In (c, e:=[])
{
For b, g In f
e[e.Length()+1]:=d g
} c:=[e*]
}
For b, a In c
c .= a " "
Msgbox % c
/*
===================================
[g] CharactersArray
[c`d] AcumArray ` (=AcumArray.Length)
[e] TempArray
-------------------------------------------------
Example::
AcumArray | CharactersArray = TempArray[result]
00 | 1 = 001
| 2 = 002
| 3 = 003
01 | 1 = 011
| 2 = 012
| 3 = 013
02 | 1 = 021
| 2 = 022
| 3 = 023
... | ... = ...
-------------------------------------------------
Note: For each "loop" use "force-expression" to save some lines.
*/