Just in case you need to profile which sub/function is performing slowly ... thinBasic has an internal profiler.
Just add the following line
in your source code and at the end of script execution you will get a window like the one attached that will show list of script functions, how many times are called, time taken to load/unload/execute, ...
In this script there are few functions executed thousand of times per seconds. Little optimizations in there will produce great results in execution speed (hopefully :D ).
Ciao
Eros