If you want to avoid the hassle of changing the priority of all your sprites you can do it the natural way without the SET SPRITE PRIORITY command.
The way Darkbasic Pro is right now sprites are drawn based on the image number used in the sprite. Sprites that use image number 1 are always under sprites that use image number 2 and so on.
In the following code snip all the sprites use random numbers between 1 and 999 while the sprite at the mouse coordinates use sprite number 1000. All sprites use image numbers 1 to 17. Hit the mouse button to change the image number used on the mouse sprite and move the mouse around the sprites on the screen. It'll be under/over each sprite based on the current image number of sprite 1000.
` Make random number picking more random
randomize timer()
` Create 17 sprites
for ImageNum=1 to 17
` Pick a random sprite number between 1 and 999
repeat
SpriteNum=rnd(998)+1
until sprite exist(SpriteNum)=0
` Create a box
ink rgb(rnd(255),rnd(255),rnd(255)),0
box 0,0,50,50
ink rgb(255,255,255),0
` Show sprite number on the box
center text 25,0,"Image"
` Show image number on the box
center text 25,30,"# "+str$(ImageNum)
` Grab the image
get image ImageNum,0,0,50,50,1
` Create the sprite
sprite SpriteNum,ImageNum*40-40,ImageNum*10,ImageNum
next ImageNum
hide mouse
` Pick a random starting image number
MImage=rnd(16)+1
tim=timer()
do
` Show the mouse
sprite 1000,mousex(),mousey(),MImage
` Check for mouseclick
if mouseclick() and timer()>tim+200
` Pick a random image number
MImage=rnd(16)+1
` Reset timer
tim=timer()
endif
loop