Quote: "and consists solely of subroutines, and it all works fine. sometimes not! What is the rule?"
#Included files are
supposed to contain only functions - not procedures/subroutines. That's not to say that having procedures in them doesn't work - I've just never tried because when I was learning to use DB the help files only said functions.
When you compile your program, the editor creates a temporary text file from your main DBA file then takes all of the #Include files and tags them on the end. This file then gets passed to the compiler.
So, the resulting exe is exactly the same as if you had created one big dba file in the first place and as such, calls to any of the functions in the #Include files from the main DBA file will work just fine.
The only things to watch out for are that you don't use the same function name in more than one #Include file and global Types are declared in the main program.
TDK_Man