Sorry about the other messages - hit tab in the code snippet an IE went nuts on me...A while back I reported a possible problem with the cSelect object. I had since decided to abandon using it - it was convenient, but I was getting unexplainable behavior that would go away when I just uses two lines of code instead of the one that cSelect offers (i.e. lnArea=select()/select(lnArea)).
I have now come up against the problem in a framework class. Specifically, when the application object instantiates, it runs the addchildren method. The last method called in that calling chain is cDatabaseMgr.MetaData.SelectDefaultDatabaseRecord(). That method has compilation directives which instruct VFP to use the NewObj() function instead of CreateObj() to create cSelect, depending on the version of VFP.
All of a sudden, I am getting bugs when that particular method runs. The cSelect method does not instantiate. In fact, the init method does not even run. I have placed debugouts in the cSelect's init method which shows the callstack for every single instantiation, and not once in the output file is there a reference to the SelectDefaultDatabaseRecord() method.
The problem disappears if CreateObj() is called instead of newobj. In other words, if I remove the compilation directive (or whatever it's called), changing the code from:
#IF VFP_VERSION >= 6
loSelect = NEWOBJ('CSelect', 'CUtils', '', 'MetaDBC')
#IF .f.
#ELSE
loSelect = CREATEOBJ('CSelect', 'MetaDBC')
#ENDIF
to
loSelect = CREATEOBJ('CSelect', 'MetaDBC')
The problem disappears.
I'm not sure if this warrants a change to the framework, since the problem is not reproducable in other circumstances, but it obviously presents problems in that I need to change the code of a framework baseclass. Why use NewObj() at all, though? I don't see the benefit, since the classlibs are already set.
No response is necessary. I write this to add to the MM Knowledge Base for future reference.