Hi again - another question; what is the best way to "fail" a constructor call? For example, I have a constructor "timage.loadimage()", and I want it to return "nil" if it encounters a problem (e.g. the file name doesn't exist). My example program is this:
type mytestclass = class bobbob : longint; constructor create; end; constructor mytestclass.create; begin inherited create; free; // *** what do I put here? result := nil; end; var bob : mytestclass; begin bob := nil; writeln('Memavail before: ',memavail); bob := mytestclass.create; writeln('Memavail after : ',memavail); writeln('Bob assigned? ',assigned(bob)); end. The problem is where the *** is marked; I don't know what to place there to do everything properly. If I use "free" then there is no memory leak, but "bob" is "assigned" (the result:=nil does nothing). I also tried "fail" (as I remember seeing it in the docs somewhere but I couldn't find it again) - if I do this bob returns "nil" as expected but there is a memory leak. Using both of them together doesn't help me either. Is there a legal way to do this? _______________________________________________ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal