Carl wrote:
> Exceptions aren't too complicated - you probably don't need a
> book on them.
> The Delphi help goes into a fair bit of detail and there are examples of
> their use in the demos.
>
> > Anyway, could you look at the following and tell me what would be
> > incorrect about the following?
>
> Seems ok to me. Although GetMem can fail too (raising an EOutOfMemory
> exception), so really you should go
>
> GetMem(PaperNameArray, PaperNameCount * cchPaperName);
> try
> GetMem(PaperSizeArray, Needed * Sizeof(Word));
> try
> GetMem(PaperIDArray, Needed * SizeOf(TPoint));
> try
> ...
> finally
> FreeMem(PaperIDArray);
> end;
> finally
> FreeMem(PaperSizeArray);
> end;
> finally
> FreeMem(PaperNameArray);
> end;
>
or another idiom for multiple allocataions that avoids multiple try
finallys:
PaperNameArray := nil;
PaperSizeArray := nil;
PaperIDArray := nil;
try
GetMem(PaperNameArray, PaperNameCount * cchPaperName);
GetMem(PaperSizeArray, Needed * Sizeof(Word));
GetMem(PaperIDArray, Needed * SizeOf(TPoint));
...
finally
FreeMem(PaperIDArray);
FreeMem(PaperSizeArray);
FreeMem(PaperNameArray);
end;
TTFN,
Paul.
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"