Here the problem is that you cannot declare an external function having the same name of thinBasic keyword.
"Sleep" is a thinBasic keyword so you get an error.
You can declare it with a different name:
Declare Sub MyVersionOfSleep Lib "kernel32.dll" Alias "Sleep" (ByVal ms As Long)
Regarding the intermittent error reported above ... I'm testing.
At first sight the only thing I've seen is that is strange is that you DIM variable inside loops and I didn't consider that fact.
Usually DIM ... should be placed outside loops.
When thinBasic see DIM <VariableName> As <VariableType> it checks if <VariableName> is already defined in the current stack level.
If yes, it check if <VariableType> is the same of the already defined variable.
If also this is true, DIM is just ignored.
But having so much DIM <VariableName> As <VariableType> = <expression> can be a problem.
Anyway ... going on in checking
Bookmarks