[Lazarus] compile errors trying to create array of tbutton.
Peter Williams
peterericwilliams at gmail.com
Sat May 21 17:37:35 CEST 2011
type
Tarray_of_tbutton = array of tbutton;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure MyArrayButtonsClick(Sender: TObject);
procedure define_3x3_button_array;
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
my_array_of_tbutton : Tarray_of_tbutton;
procedure TForm1.define_3x3_button_array;
const
max_horizontal = 3;
max_vertical = 3;
var
v_count, h_count, array_count : integer;
begin
SetLength( my_array_of_tbutton, max_horizontal * max_vertical );
for v_count := 0 to max_vertical - 1 do
for h_count := 0 to max_horizontal - 1 do
begin
array_count := v_count * max_horizontal + h_count;
my_array_of_tbutton[ array_count ] := new( tbutton(
my_array_of_tbutton ));
my_array_of_tbutton[ array_count ].Parent := Self;
my_array_of_tbutton[ array_count ].Left :=
50 + h_count * 50;
my_array_of_tbutton[ array_count ].Top :=
50 + v_count * 50;
my_array_of_tbutton[ array_count ].Tag :=
array_count;
my_array_of_tbutton[ array_count ].OnClick :=
myArrayButtonsClick;
my_array_of_tbutton[ array_count ].Caption :=
inttostr( array_count );
end;
end;
Full code is here: http://pastebin.com/ueKmjkrC
Options changed, recompiling clean with -B
Hint: Start of reading config file /etc/fpc.cfg
Hint: End of reading config file /etc/fpc.cfg
Free Pascal Compiler version 2.5.1 [2011/05/14] for i386
Copyright (c) 1993-2011 by Florian Klaempfl and others
Target OS: Linux for i386
Compiling slide_puzzle.lpr
Compiling unit1.pas
unit1.pas(52,81) Error: Type identifier expected
unit1.pas(61,29) Error: Wrong number of parameters specified for call
to "MyArrayButtonsClick"
unit1.pas(34,18) Hint: Found declaration: TForm1.MyArrayButtonsClick(TObject);
unit1.pas(67,18) Error: overloaded functions have the same parameter list
unit1.pas(34,18) Hint: Found declaration: TForm1.MyArrayButtonsClick(TObject);
unit1.pas(67,18) Error: function header doesn't match any method of
this class "TForm1.MyArrayButtonsClick(TObject);"
unit1.pas(34,18) Hint: Found declaration: TForm1.MyArrayButtonsClick(TObject);
unit1.pas(79) Fatal: There were 4 errors compiling module, stopping
Best Regards,
Peter
More information about the Lazarus
mailing list