program russ3b;

const MAXLINES = 20000;

type
  lline         = string ( 4000 );      {buffer for data xfer}

procedure foo;
var
  cap : integer;

type
  ptrline  = ^String;
  Line = string ( cap );

  TbbArray      = array[1..MAXLINES] of ptrline;

var
  BigBuffer  : Tbbarray;                {array of pointers to data}
  LineCount  : integer = 0;

procedure BB_AddLine( Aline: lline );
begin
  cap := Length (ALine);
  inc( LineCount );
  BigBuffer[ LineCount ] := new( ptrline, cap );
  BigBuffer[ LineCount ]^ := Aline;
end;

begin
  BB_AddLine ('OK');
  if LineCount = 1 then WriteLn (BigBuffer[1]^) else WriteLn ('failed ', LineCount)
end;

begin
  foo
end.
