Re: [Lazarus] How write a proper Type declaration with procedures?

2015-10-28 Thread Anthony Walter
type
  TURLTable = class(TStringlist)
  private
FTable: LinkArray;
function GetTable: LinkArray;
  public
 procedure Insert(const s: string);
 property Table: LinkArray read GetTable;
  end;

function TURLTable.GetTable: LinkArray;
begin
  Result := FTable;
end;

procedure TURLTable.Insert(const s: string);
begin
end;

... or alternately

  property Table: LinkArray read FTable;


... and remove function GetTable: LinkArray;
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How write a proper Type declaration with procedures?

2015-10-28 Thread leledumbo
> When I come to write the implementation part of the unit, what's the syntax
to refer to the property Table? If I use 
> ...
> I get the error 'No member is provided to access property.'

That should be correct. It's something else that bugs. At least the
following compiles for me:

unit Simple;

{$mode objfpc}{$H+}

interface

uses
  Classes;

type
  TURLTable = class(TStringList)
  private
Table: array of String;
  public
procedure Insert(const s: String); overload;
  end;

implementation

procedure TURLTable.Insert(const s: String);
var
  i: Integer;
begin
  i := Length(Table);
  SetLength(Table,i + 1);
  Table[i] := s;
end;

end.




--
View this message in context: 
http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-How-write-a-proper-Type-declaration-with-procedures-tp4045029p4045031.html
Sent from the Free Pascal - Lazarus mailing list archive at Nabble.com.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How write a proper Type declaration with procedures?

2015-10-28 Thread Joe Shepherd

Thank you both - another case of not seeing the wood for the trees.

 

Joe

 

 
 



--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus