Try adapting this to your needs :
type t_Zone
active as integer
x1 as integer
y1 as integer
x2 as integer
Y2 as integer
endtype
sync on
global dim MyZone(10) as t_Zone
for i=0 to 10
x=rnd(630)
y=rnd(470)
MakeZone(i, x, y, x+10, y+10)
next i
do
box 0, 0, 640, 20, 0, 0, 0, 0
Z=FindZone(mousex(), mousey())
if Z >= 0 then text 0, 0, "Mouse is in zone : " + str$(Z)
sync
loop
function MakeZone(Z as integer, x1 as integer, y1 as integer, x2 as integer, y2 as integer)
MyZone(Z).x1=x1
MyZone(Z).y1=y1
MyZone(Z).x2=x2
MyZone(Z).y2=y2
MyZone(Z).active=1
box x1, y1, x2+1, y2+1
endfunction
function DeleteZone(Z as integer)
MyZone(Z).active=0
endfunction
function InZone(Z as integer, x as integer, y as integer)
if MyZone(Z).active = 0 then exitfunction 0
if x < MyZone(Z).x1 then exitfunction 0
if x > MyZone(Z).x2 then exitfunction 0
if y < MyZone(Z).y1 then exitfunction 0
if y > MyZone(Z).y2 then exitfunction 0
endfunction 1
function FindZone(x as integer, y as integer)
local Z as integer
for Z=0 to 10
if InZone(Z, x, y) then exitfunction Z
next Z
endfunction -1