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
Russell Whitaker wrote:
type ptrline = ^Line; Line = string ( );
just replace this by
type ptrline = ^string;
You do not need cap, and a faulty construct, even if the compiler misses an error.
Maurice
On Wed, 19 Dec 2001, Maurice Lombardi wrote:
Russell Whitaker wrote:
type ptrline = ^Line; Line = string ( );
just replace this by
type ptrline = ^string;
You do not need cap, and a faulty construct, even if the compiler misses an error.
Just now tried it. Seems strange, but it works.
Thanks, Russ
Russell Whitaker wrote:
On Wed, 19 Dec 2001, Maurice Lombardi wrote:
Russell Whitaker wrote:
type ptrline = ^Line; Line = string ( );
just replace this by
type ptrline = ^string;
You do not need cap, and a faulty construct, even if the compiler misses an error.
Just now tried it. Seems strange, but it works.
What's so strange about it. It's kind of like arrays. You use `ArrayVar[IndexValue]' to refer to a single element and just `ArrayVar' to refer to the whole array. Similarly, `String (Cap)' is a string of given capacity and just `String' is a string of arbitrary capacity (only valid in pointers and var parameters).
Frank