Would this be of any assistance? I found it in the code archives, and I haven't tested it myself, but it might be the kind of thing you're looking for.
http://www.blitzbasic.com/codearcs/codearcs.php?code=246>edit
Oops! The post before wasn't there when I posted this! It sounds better too! Oh well, this may be handy.