Nice! but the only problem is with one call of you function you can only delete 1 object, 1 matrix, and 1 sprite at a time. So in essence you really don't save yourself any time or space with the function.
Us the for next loop like this.....
function deleteall(maxobj,maxmat,maxspr)
rem delete objects
for i=1 to maxobj
if object exist(i)=1
delete object i
endif
next i
rem delete matrices
for i=1 to maxmat
if matrix exist(i)=1
delete matrix i
endif
next i
rem delete sprites
for i=1 to maxspr
if sprite exist(i)=1
delete sprite i
endif
next i
endfunction
This function will delete all existing objects,matrices and sprites with one command.