This is a sinept of a bigger code. that code has a problem and I was trying to solve the problem without having to rewrite the whole code.
In order to solve the problem I need to teel the code to associate a position with each number.
Example:
For this sequence:
"sim := "1 10 11 12 13 14 15 16 17 18 19 2 20 21 22 3 4 5 6 7 8 9 1 10 11 12 13 14 15 16 17 18 19 2 20 21 22 3 4 5 6 7 8 9 1 10 11 12 13 14 15 16 17 18 19 2 20 21 22 3 4 5 6 7 8 9 1 10 11 12 13 14 15 16 17 18 19 2 20 21 22 3 4 5 6 7 8 9
I need the code to associate:
Code: Select all
1 - 1
10 - 10
11 - 11
12 - 12
13 - 13
14 - 14
15 - 15
16 - 16
17 - 17
18 - 18
19 - 19
2 - 2
20 - 20
21 - 21
22 - 22
3 - 3
4 - 4
5 - 5
6 - 6
7 - 7
8 - 8
9 - 9
1 - 23
10 - 32
11 - 33
12 - 34
13 - 35
14 - 36
15 - 37
16 - 38
17 - 39
18 - 40
19 - 41
2 - 24
20 - 42
21 - 43
22 - 44
3 - 25
4 - 26
5 - 27
6 - 28
7 - 29
8 - 30
9 - 31
1 - 45
10 - 54
11 - 55
12 - 56
13 - 57
14 - 58
15 - 59
16 - 60
17 - 61
18 - 62
19 - 63
2 - 46
20 - 64
21 - 65
22 - 66
3 - 47
4 - 48
5 - 49
6 - 50
7 - 51
8 - 52
9 - 53
1 - 67
10 - 76
11 - 77
12 - 78
13 - 79
14 - 80
15 - 81
16 - 82
17 - 83
18 - 84
19 - 85
2 - 68
20 - 86
21 - 87
22 - 88
3 - 69
4 - 70
5 - 71
6 - 72
7 - 73
8 - 74
9 - 75
If a number is less than the highest number so far:
associate it with a postion matching its own value:
Code: Select all
1 - 1
10 - 10
11 - 11
12 - 12
13 - 13
14 - 14
15 - 15
16 - 16
17 - 17
18 - 18
19 - 19
2 - 2
20 - 20
21 - 21
22 - 22
3 - 3
4 - 4
5 - 5
6 - 6
7 - 7
8 - 8
9 - 9
Code: Select all
1 - 23
10 - 32
11 - 33
12 - 34
13 - 35
14 - 36
15 - 37
16 - 38
17 - 39
18 - 40
19 - 41
2 - 24
20 - 42
21 - 43
22 - 44
3 - 25
4 - 26
5 - 27
6 - 28
7 - 29
8 - 30
9 - 31
1 - 45
10 - 54
11 - 55
12 - 56
13 - 57
14 - 58
15 - 59
16 - 60
17 - 61
18 - 62
19 - 63
2 - 46
20 - 64
21 - 65
22 - 66
3 - 47
4 - 48
5 - 49
6 - 50
7 - 51
8 - 52
9 - 53
When another one is found, we repeat the procedure, adding the highest number before the one appearing to the subsequent numbers (until a new one is found)
Code: Select all
1 - 67
10 - 76
11 - 77
12 - 78
13 - 79
14 - 80
15 - 81
16 - 82
17 - 83
18 - 84
19 - 85
2 - 68
20 - 86
21 - 87
22 - 88
3 - 69
4 - 70
5 - 71
6 - 72
7 - 73
8 - 74
9 - 75
Code: Select all
#SingleInstance, Force
SetTitleMatchMode, 2
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
sim := "1 10 11 12 13 14 15 16 17 18 19 2 20 21 22 3 4 5 6 7 8 9 1 10 11 12 13 14 15 16 17 18 19 2 20 21 22 3 4 5 6 7 8 9 1 10 11 12 13 14 15 16 17 18 19 2 20 21 22 3 4 5 6 7 8 9 1 10 11 12 13 14 15 16 17 18 19 2 20 21 22 3 4 5 6 7 8 9"
StringSplit, sim, sim, %a_space%
t := 0
x := 0
listing := 1
messagebox := ""
loop %sim0%
{
x := x + 1
big%x% := 0
}
loop %sim0%
{
t := t + 1
value := sim%t%
position := sim%t% ; simulates h := RegExReplace(ACTIVIDADE_%z%_TITULO__FICHEIRO%y%, "\D") ; catch the number in the filename
if (position = 1)
{
listing := listing + 1
}
previouslisting := listing - 1
if (listing = 2)
{
position := position + big%previouslisting%
;~ listing := 3
}
big := big%listing%
if (position >= big){
big := position
;~ msgBox,,, % big
}
messagebox .= "value: " . value . " --- position: " . position . "`r`n"
}
MsgBox,,, %messagebox%
exitapp
^Esc::
ExitApp
return