Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-10

How write a proper Type declaration with procedures?

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

leledumbo
to Joe Shepherd
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.
Anthony Walter
to Joe Shepherd: An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/laz…
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;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151028/03939785/attachment.html>