is there any TP code or assembly code to trap overflow errors in the TP. please write code here. thanks.
thank you himanshu s. but i couldn't find SysUtils.tpu or classes tpu under my tp/units folder.
where to find them and how to use stack unit. which procedures or function, when to call?
Related posts:








1 response so far ↓
1 himanshu s // Jun 11, 2008
well you can understand overflow logic using stack concept ……..
i am writing stack algo in Pascal………
/*statck*/
unit Stack;
interface
uses
SysUtils, Classes;
type
TStack = class
private
FList: PPointerList;
FCapacity, FCount: Cardinal;
procedure Grow;
public
destructor Destroy; override;
procedure Push( const Data: Pointer );
function Pop: Pointer;
end;
implementation
{ TStack }
destructor TStack.Destroy;
begin
FreeMem( FList );
inherited;
end;
procedure TStack.Grow;
begin
if FCapacity > 64 then
Inc( FCapacity, FCapacity div 4 )
else
if FCapacity > 8 then
Inc( FCapacity, 16 )
else
Inc( FCapacity, 4 );
ReallocMem( FList, FCapacity * SizeOf( Pointer ) );
end;
function TStack.Pop: Pointer;
begin
if FCount > 0 then
begin
Dec( FCount );
Result := FList^[FCount];
end
else
Result := nil;
end;
procedure TStack.Push(const Data: Pointer);
begin
if FCapacity = FCount then
Grow;
FList^[FCount] := Data;
Inc( FCount );
end;
end.
Bye:)
Leave a Comment