I am not certain what to do to correct an error that appears in my code. This error seems rather straight forward, but the circumstances are not what you might imagine. The compiler error is:"Undefined TYPE Declare Sub ShowCHAINForm(ByRef Rec as RecBuff, ByRef DetailIDs() As Stirng)"
Here is the situation:
I have a GUI program that compiles to around 1 MB in size of the executable. There are 30 modules/forms in this program. One of these modules contains a series of several dozen functions and subs to manage database access using TSUNAMI. It also contains quite a number of global variables which follow all of the sub and function declarations at the top of the module and above the source code.
Here is the strange thing. I had built three large subs used to generate a bunch of demo data for my database tables. The main demo-builder routine was called in only two places. I removed the calls to the demo-data builder from the other routines where they existed. I then proceeded to comment out all of the code for these routines, I removed the source code for these routines from the inside out (the ones called by other ones first) and recompiled with each step to make sure there were no other calls to each of the three routines. The code compiled fine each time. As I mentioned, these were large routines. Doing this reduced the executable by around 200k in size.
When I then commented out the three declarations and a global array the compiler spit out the error mentioned above... Undefined TYPE...
The sub declared as in error (ShowCHAINForm) is in a totally different module and has compiled perfectly fine and has done so for months.
This error happened, not when I commented out the code for the three routines, but when I commented out the declarations. I narrowed the situation down to only one of the three declarations in my database module. I deleted the other two and the global array. The one causing the problem was the last declaration, and it happens that it is also the last one of the dozens of declarations in the database module right before the globals. If I leave in the declaration the program compiles fine. If I comment the declaration out, the other sub is flagged with an error. If I move the declaration to the very top of the database module the error still happens.
Of course, there is no code related to that sub any more. It was all deleted. So I even changed the name of the declaration as in:
Declare Sub thisisjunk()
This had the same result. I comment out the junk declaration and the ShowCHAINForm error is tagged. If I uncomment the declaration, the program compiles and runs fine. ???
I suspect there is something else wrong. Anyone have any ideas where I can go with this? I do not want to leave whatever error is actually in the code, but there is way too much code to experiment blindly.
Thanks in advance,
Dwight
I am pretty sure that the problem lies in the way that FireFly collects the declares for the functions, globals, types and equates. It is probably generating the source code with the RecBuff Type declaration being placed after the "ByRef Rec as RecBuff" in the function declaration. When the compiler attempts to compile, it sees the "ByRef Rec as RecBuff" before it sees the actual definition for the RecBuff Type therefore causing the error. This is a by-product of the compiler not being able to handle forward references - something that FireFly tries to accommodate by generating all of the declares/types/globals, etc... for you in the background.
To fix the problem, maybe the best bet is to move your function declare and type definition manually from your module into a special text file that you create and resides in the same folder as your project file (*.prj).
Check out these posts:
http://planetsquires.com/support/index.php?topic=2187.0
http://planetsquires.com/support/index.php?topic=2075.0
Thanks Paul,
I appreciate the help. I've been away from the project for a while so was not able to review your reply till now.
I will remove my lines of declaration from each of the modules and place them in separate filea and include references in User_Includes.inc.
Dwight
Paul...
Removing the includes into separate files and then adding the various... #INCLUDE "includefile.inc" entries into User_Includes.inc worked great. The compiler issue has gone away.
Once again you have come through with a simple fix to an issue that had me completely bafled. Thanks for the great support. BTW, I for one will be happy to pay an upgrade fee for FF V3! ;D Your support has been out and away the best I've ever experienced. Thanks!
DDS-
Thanks Dwight, I appreciate the kind words :)
BTW, In FireFly 3 you will have access to a new section of code called FF_AppStart. Basically, this will allow you to place all of your compiler directives and #include files. It makes it much easier to have total control over your code. Here is the default FF_AppStart code that can be modified or added to by the user:
#COMPILE EXE "Project1.exe"
' #BLOAT <num_expr>
' #COMPILER PBWIN
' #DEBUG ERROR ON|OFF
' #DIM ALL|NONE
' #OPTION {VERSION3 | VERSION4 | VERSION5}
' #REGISTER {ALL | DEFAULT | NONE}
' #TOOLS [ON|+ | OFF|-]
' #STACK <num_expr>
#Include "WIN32API.INC"
#Include "COMMCTRL.INC" ' needed for WinXP Theme support
#Include "COMDLG32.INC"
#Include "RICHEDIT.INC"
' Place your user defined Declares, Constants, and #Include files below this line. FireFly will not
' parse any of your defined #Include files - it simply includes it in the final generated code.
' -------------------------------------------------------------------------------------------------