Sign in Join

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

Mailing lists / lazarus / 2013-07

Procedure variables

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Timothy Groves

Okay, I've spent an hour googling this one, and got no information that helps. I want to declare four methods as being procedural variables, so that I can set them and call them. Code follows. When I try to compile this, I get:

glanguage.pas(37,20) Error: Incompatible types: got "<address of function:AnsiString;Register>" expected "tLanguage.<procedure variable type of procedure;Register>".

What am I doing wrong?

unit glanguage;
{$mode objfpc}{$H+}
interface
uses
   Classes, SysUtils;
type
   tLanguage = class (tObject)
     private
       t_ClanNames : array of string;
       t_language : integer;
       procedure SetLanguage (a : integer);
     public
       FirstName : procedure;
       LastName : procedure;
       ClanName : procedure;
             PlaceName : procedure;
       property Language : integer read t_language write SetLanguage;
   end;
implementation
uses
   wrdsaxon;
const
   LG_NONE = 0;
     LG_SAXON = 1;
procedure tLanguage.SetLanguage (a : integer);
begin
   case a of
         LG_SAXON : begin
       FirstName := @SaxonMale;
       LastName := @SaxonFemale;
       ClanName := @SaxonFamily;
       PlaceName := @SaxonPlace;
       end;
   end;
end;
end.

Reply by email

Guionardo Furlan
to Timothy Groves: Okay, I've spent an hour googling this one, and got no information that helps. I want to…

Use TProcedure as type of the properties.

2013/7/27 Timothy Groves

Show quoted text 66 lines
Okay, I've spent an hour googling this one, and got no information that helps. I want to declare four methods as being procedural variables, so that I can set them and call them. Code follows. When I try to compile this, I get: glanguage.pas(37,20) Error: Incompatible types: got "<address of function:AnsiString;Register>" expected "tLanguage.<procedure variable type of procedure;Register>". What am I doing wrong? unit glanguage; {$mode objfpc}{$H+} interface uses Classes, SysUtils; type tLanguage = class (tObject) private t_ClanNames : array of string; t_language : integer; procedure SetLanguage (a : integer); public FirstName : procedure; LastName : procedure; ClanName : procedure; PlaceName : procedure; property Language : integer read t_language write SetLanguage; end; implementation uses wrdsaxon; const LG_NONE = 0; LG_SAXON = 1; procedure tLanguage.SetLanguage (a : integer); begin case a of LG_SAXON : begin FirstName := @SaxonMale; LastName := @SaxonFemale; ClanName := @SaxonFamily; PlaceName := @SaxonPlace; end; end; end; end. -- ______________________________**_________________ Lazarus mailing list .**freepascal.org http://lists.lazarus.**freepascal.org/mailman/**listinfo/lazarus<http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus>
*Timeo hominem unius libri* []s Guionardo Furlan http://www.guionardofurlan.com.br -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130729/b789fbc2/attachment.html>

Reply by email