Posts: 81
Threads: 31
Joined: Mar 2015
I really don't understand reference variables
in AHK, something like this...
Loop, 5
{
N:=N+1
A%N%:=N
}
Return
And I don't know what to do in QM especially %N%... Help me bros...
Posts: 12,062
Threads: 140
Joined: Dec 2002
I guess A%N% is N-th element of array A. Then in QM would be:
Macro
Macro2522
int N
ARRAY(int) A.create(5) ;;create 0-based array of 5 elements
rep 5
,N+1
,A[N-1]=N ;;set element
ret
or
Macro
Macro2522
int N
ARRAY(int) A.createlb(5 1) ;;create 1-based array of 5 elements
rep 5
,N+1
,A[N]=N ;;set element
ret
or
Macro
Macro2522
int N
ARRAY(int) A
rep 5
,N+1
,A[]=N ;;add and set element
ret
Posts: 81
Threads: 31
Joined: Mar 2015
OH THANK YOU VERY MUCH SIR...
BTW is variable A1, A2, A3, A4, A5 same?
is the result A[1] A[2].... or something?
Posts: 81
Threads: 31
Joined: Mar 2015
I Tried
out A[]
is 0
but
out A[5]
is
"Error (RT) in <open ":1: /4795">Macro2: invalid index. <help #IDP_ERR>?"
Posts: 12,062
Threads: 140
Joined: Dec 2002
int A1, A2, A3, A4, A5
five variables
ARRAY(int) A
A[1], A[2] etc are elements of variable A
Posts: 12,062
Threads: 140
Joined: Dec 2002
A[] adds one element, ie resizes the array
A[5] is sixth element of 0-based array. The array must have 6 or more elements, else error.
ARRAY(int) A.create(5)
out a[0]
out a[1]
out a[2]
out a[3]
out a[4]
out a[5] ;;error, the array does not have a[5]
Posts: 81
Threads: 31
Joined: Mar 2015
Thank you very very much... I learned it...
I decided use creatlb method Not to confuse... it seems...
Have a good day~~
Posts: 12,062
Threads: 140
Joined: Dec 2002
I saw your PixelSearch function, then the topic disappeared. It would be correct, but function pixel() is slow... This is faster version:
Function
PixelSearch
function# SX SY EX EY color [VAR] [POINT&p]
;Searches a region of the screen for a pixel of the specified color.
;Returns: 1 found, 0 not.
;SX, SY - top-left coord of the search region relative to the active window.
;EX, EY - bottom-right coord. The point is inside the search region.
;color - search for this pixel color, in 0xBBGGRR format.
;VAR - allowed color component difference, 0-255.
;p - optional POINT variable that receives found pixel coordinates in screen.
;EXAMPLE
;POINT p
;if PixelSearch(552 21 592 51 0x2f59fd 0 p)
;,mou p.x p.y
opt noerrorshere 1
RECT r; SetRect &r SX SY EX+1 EY+1
if(!scan(F"color:{color}" win r 0 VAR)) ret
if(&p) p.x=r.left; p.y=r.top
ret 1
Posts: 81
Threads: 31
Joined: Mar 2015
WOW (-.-);; Thank you I'll try this .... wow wow...
I'm trying to fly on earth and you're exploring space..;
Posts: 81
Threads: 31
Joined: Mar 2015
"Error (RT) in Macro2: object not found. "
repeats..
I called your Function like this
DX = PixelSearch(123 123 123 123 0xFFFFFF 3)
Posts: 12,062
Threads: 140
Joined: Dec 2002
Sorry, must be scan(F"color:{color}" win r 0 VAR), not scan(F"color:{color}" win r VAR). Now fixed.