Q: I have 2 heavily used BP7 libraries to migrate to Delphi. Both use a lot of collections & Streams. I'm probably not alone in this situation. Can we mix Objects & classes in the same application? If not, I'm ready to dump Streams, but can collections be saved???
Is there any way of saving that code without a major rewrite?
(I tried to USES OBJECT but I'm getting all sorts of compiler complaints...)
A: Yes, it's actually pretty straightforward - I have a lot of code that does that. I have Objects as the first item in my "uses" statement. You DO need to tell Delphi where to find the OWL run-time library source (\delphi\source\rtl70, I think). Then, you just do either
anObject := new(PMyObject, init);
for old-style or
anObject := TMyObject.create;
for new-style objects. Make sure you don't mix up which is which though, or you'll get compiler "invalid variable reference" messages (which sometimes confuse me if I've accidentally treated an old-style object like a VCL one, or vice versa).
In fact I prefer the old streaming in many ways. As far as I can
see, you need to descend an object from TComponent in order to get automatic
streaming in VCL.