Well, you've declared no vars, placed vars in strings (although the warning on line 72 is OK, because it's a string that KF will execute). You haven't posted the entire file, so there's no way to tell where the actual error is, and the two functions you did post generated 25 warnings in a sanity check. There's no indenting of loops, commenting, identification of code sections - I could go on...

The warnings will give you an idea of how you should code when working on complex projects ("complex" being a relative term). Not counting the code you commented out, there are only two comments in the entire 145 lines. How will you understand the code next week? How do you expect others to understand your intentions.

I'm not picking on YOU, I'm making observations on code placed in the Advanced Scripting forum. These are things that advanced scripts need - it's a style you develop. Simple scripts don't need these things, but complex ones demand them. As you (and anyone else reading this) embarks on more advanced projects, you will need to develop a more formalized style and structure.

Comments - lots of them! On large projects, my Comment:Code ratio is about 55% - thats 55 lines of comments and 45 lines of code. They help you (and others) visualize the project in natural language - no coding or miscoding to interpret.

Declaration of variables - getting into using functions without declaring vars to limit their scope can have bizzare effects. You can Dim several vars on a single line, but I prefer to Dim one var per line, with a descriptive comment. If I have several temp or index pointers, I'll dim them all together, but most vars have their own declaration and written definition. No more wondering "WTF did THAT var represent???"

Code Formatting - indentation of If and Loop constructs goes a long way in readable code. So does consistent line spacing - such as
Three lines before function declarations; two lines after unique code sections; one line after every EndIf or Loop terminator so you can see where the logic sections end. Consistent indenting with spaces, not tabs - especially for code you post, where tabs make for unreasonably long lines. If a post isn't easily readable, it won't get prompt attention - just human nature.

"Empty" logic - "If X=3 Else do this EndIf" - Is something missing? Do we not want to do things when X=3? Try "negative logic" instead:
If NOT X=3
do something...
EndIf

Again, the intention is clear, nobody is left wondering if some part of code got accidentally deleted.

So - just a couple of comments to give you and all those embarking on projects that push your limits.. It's how we get better, learn, and ultimately excel. Just realize that when you go from building that treehouse to building a skyscraper, you'll need to learn and use new techniques.

You might want to take the weekend to review your code, add some of the things discussed, and post the complete package back. There are lots of us here willing to help (significantly), but "you" (anyone reading and seeking help) need to help the rest of us with good, solid information about your code and your project. We are at a disadvantage, not having sat in your chair, walked in your shoes, or (enjoyed??) a Vulcan mind-meld. \:\)

Glenn
_________________________
Actually I am a Rocket Scientist! \:D