thanks jaco, I never imagined it could be done that way.
So, here is my script which checks if a passed array contains repeated elements. Regarding the line 14 and 16, why couldn't they be written in an usual way like %arrayname0% and arrayname%A_Index%?
Code:
01: colors = red`nblue`ngreen`nred`n
02: StringSplit, color_array, colors, `n
03:
04: if chk_same_element("color_array")
05: MsgBox True
06: else
07: MsgBox False
08:
09: chk_same_element(arrayname)
10: {
11: global
12: num_chk := %arrayname%0
13: counter := 0
14: Loop, %num_chk% ;1. Loop, %arrayname0% didn't work
15: {
16: array_element%A_Index% := %arrayname%%A_Index% ;2. arrayname%A_Index% didn't work
17: if array_element%A_Index%
18: {
19: counter += 1
20: chked_elements%counter% := array_element%A_Index%
21: }
22: }
23: repeated =
24: Loop, %counter%
25: {
26: chkelement := chked_elements%A_Index%
27: scan_number := A_Index
28: Loop, %counter%
29: {
30: if (A_Index = scan_number)
31: continue
32: else if (chkelement = chked_elements%A_Index%)
33: {
34: repeated := true
35: break
36: }
37: }
38: }
39: if repeated
40: return true
41: else
42: return false
43: }