If you take the listing and make some minor changes so it looks like:
unit Buff; interface
const MAXLINES = 20000;
type lline = string ( 4000 );
procedure BB_AddLine( Aline: lline ); {adds to end}
implementation { var cap : integer;}
type ptrline = ^Line; Line = string ( );
TbbArray = array[1..MAXLINES] of ptrline;
var BigBuffer : Tbbarray; {array of pointers to data} LineCount : integer = 0;
procedure BB_AddLine( Aline: lline ); begin inc( LineCount ); BigBuffer[ LineCount ] := new( ptrline, length( Aline )); BigBuffer[ LineCount ]^ := Aline; end; end.
Compile the above, you get:
buff.pas:17: parse error before `)' buff.pas:17: missing expression buff.pas:17: warning: missing string capacity - assuming 255 buff.pas: In procedure `Bb_addline': buff.pas:28: too many arguments to `New'
Now, uncomment lines 12,13 so it reads var cap: integer; And add in cap to line 17 so it reads Line = string( cap ); The unit now compiles and works as expected. (creates strings with capacity = length at runtime)
Russ