You can use the SPRITE EXIST() command to see if a particular sprite exists. If you want to check for all sprites you use a FOR/NEXT loop to run that command through all the sprites you may have in your program.
` Make random number picking more random
randomize timer()
` Make an image
ink rgb(100,100,100),0
box 0,0,50,50
get image 1,0,0,50,50,1
` Create 50 sprites
for t=1 to 50
` Create a random sprite number 1 - 1000
sprite rnd(999)+1,rnd(screen width()),rnd(screen height()),1
next t
` Check if the file about to be open exists
if file exist("Sprites.txt") then delete file "Sprites.txt"
` Open a .txt file to list the sprites
open to write 1,"Sprites.txt"
` Check all possible sprites
for t=1 to 1000
` Check if the current sprite exists
if sprite exist(t)
` Write the sprite number that exists
write string 1,"Sprite #"+str$(t)+" exists"
endif
next t
` Close the .txt file
close file 1
` Show the .txt file with notepad
execute file "Notepad.exe","Sprites.txt",""
wait key
The above will work if you add to the array instead of writing to a file... but generally if you want a sprite number to be recorded in an array you do that right after the sprites creation. If you do that you don't have to later try to figure out which sprites exists with a FOR/NEXT loop.