Class definitions are moved here. I have been using classes in FF for several months with no problems. I have been accessing FF generated global variables (HWND_MAIN_MLG1 for instance) in the classes without problems also.
When I tried to use a global I defined, however, I got a compile time error of 516. Here is an excerpt from the ...DECLARES.inc file: (Quote instead of Code so I could use highlighting)
QuoteIf GetParent(hCtrl) = gMEView Then ':FILE:CODEGEN_CONTROLRELATIONSHIPS_MODULE2INC_MODULE.inc|245|0
For i = 0 To 17 ':FILE:CODEGEN_CONTROLRELATIONSHIPS_MODULE2INC_MODULE.inc|246|0
For j=0 To 17 ':FILE:CODEGEN_CONTROLRELATIONSHIPS_MODULE2INC_MODULE.inc|247|0
If Bit(DV(i), j) =1 Then x$="X" Else x$="" ':FILE:CODEGEN_CONTROLRELATIONSHIPS_MODULE2INC_MODULE.inc|248|0
MLGPUT (HWND_MAIN_MLG1,i+1,j+1,x$,0) ':FILE:CODEGEN_CONTROLRELATIONSHIPS_MODULE2INC_MODULE.inc|249|0
Next j ':FILE:CODEGEN_CONTROLRELATIONSHIPS_MODULE2INC_MODULE.inc|250|0
Next i ':FILE:CODEGEN_CONTROLRELATIONSHIPS_MODULE2INC_MODULE.inc|251|0
MLGPUT(HWND_MAIN_MLG1,i,j,x$,1) ':FILE:CODEGEN_CONTROLRELATIONSHIPS_MODULE2INC_MODULE.inc|252|0
End If ':FILE:CODEGEN_CONTROLRELATIONSHIPS_MODULE2INC_MODULE.inc|253|0
End Method ':FILE:CODEGEN_CONTROLRELATIONSHIPS_MODULE2INC_MODULE.inc|254|0
End Interface ':FILE:CODEGEN_CONTROLRELATIONSHIPS_MODULE2INC_MODULE.inc|263|0
End Class ':FILE:CODEGEN_CONTROLRELATIONSHIPS_MODULE2INC_MODULE.inc|265|0
Global RZMain As ResizeInterface
Global CMOldTestForm As CtrlMgrInterface
Global MERec() As MERecType
Global gCtrlFlags As Long
Global gCtrlX As Long
Global gCtrlY As Long
Global gMainEvent As EventType
Global gMEView As dword
Global CMTestForm As CtrlMgrInterface
Declare Function MAIN_Show( ByVal hwndParent As Dword, _
ByVal ShowModalFlag As Long, _
Optional ByVal UserData As Long _
) As Long
Declare Sub MAIN_CreateControls( ByVal hWndForm As Dword )
As you can see, the global definition falls below the class definition. You can't see them in this excerpt, but the FF generated global variables are defined above the class definition - which explain why I can reference them in the class. When I manually move the declaration up, I get a clean compile and it works as designed.
Since class definition include code, maybe they should go in another file? I'm sure you had some reason for placing them here. Perhaps they should at least be moved to the bottom of the file.
David
It is a chicken and egg problem. If I move the globals before the classes then you will get an error on lines like:
Global CMOldTestForm As CtrlMgrInterface
..because the interface is not defined when the global interface variable is declared.
I think that a solution would be is to avoid globals in classes (which I don't think is a good programming practice?). Create a property called something like MeView and assign that to do your comparisons rather than the global gMeView. Might work.
Paul,
I see, and agree with, your points. I should have put a question mark on the end of the subject.
I can think of several better ways to do what I was attempting. I was trying to test something quickly instead of figuring out a more elegant method (no pun intended).
Thanks for the tips.
David