I get the impression that you are not the person that wrote the code you are working with - if you did, you'd understand what the function did. I also have to assume that you don't understand what most of the code does.
If this is correct then it's unlikely that anyone will help as you probably wouldn't understand the advice they give you.
Are you new to programming in Dark Basic?
If so, the way you are doing things is doomed to failure. You cannot learn how to program properly this way. You need to learn the basics from the help files and tutorials - building up your knowledge a bit at a time.
Sorry if this isn't the answer you were hoping for.
TDK_Man