Well, I was not being clear...I meant that it would not initialize the first element of the array, not...it won't run...my bad. Tks to BatVink for keeping it straight.
I did not look very closely at the code, and I made the same error that you are making, but...let's clear up the trouble with array subscripts first, because that is why I posted in the first place.
Array subscripts start with 0 in DBPro, so an array with a single element has only 0 for valid subscripts.
The error is on line 19 for me, which uses 'n' to reference the array. At that point in the code, n = 1, which is an illegal value, since the array has only one element, which is element 0. So, you can either use x like the loop does, or use n, but put it in the for/next lines....see what I mean?
You used n to initialize the array, and then you are using x in the loop definition, but n again in the body of the loop, therein lies the error. Also, I moved the state changing so that it is all in the proper place.
type enemy
idle as boolean
chasing as boolean
endtype
dim enemies(1) as enemy
for n = 1 to 1
enemies(n).idle = 1
next n
do
cls
for x = 0 to 1
if enemies(x).idle = 1
text 0,0,"IDLE"
endif
if enemies(x).chasing = 1
text 0,0,"CHASING"
endif
if mouseclick()=1
enemies(x).idle = 1
enemies(x).chasing = 0
endif
if mouseclick()=2
enemies(x).chasing = 1
enemies(x).idle = 0
endif
next x
loop