-2

so I have some work to do using lazarus and one of my procedures is written in a second unit but also used in the first. The problem is, I want to give the procedure a TImage from the Form connected to unit 1, but unit 2 can't find an identifier "TImage".

interface
procedure Bewegen(Spieler:TImage);

..

procedure Bewegen(Spieler:TImage);
var Lefti,Topi:integer;

function wurf(AnzahlWurfel:integer):integer;
begin
  randomize;
  case AnzahlWurfel of 1 : result:=1+Random(6);        //AZ von 1 bis 6 oder 12. Je nach Anzahl der Würfel.
                       2 : result:=1+Random(12);
  end;
end;

procedure gehen(Wurf:integer;out Left, Top:integer);
var i:integer;
begin
  for i:=1 to Wurf do if (Left<908) AND (Top=56) then Left:=Left+90//oben links nach oben rechts
                  else if (Left=908) AND (Top<956) then Top :=Top+90 //oben rechts nach unten rechts
                    else if (Left>8) AND (Top=956) then Left:=Left-90//unten rechts nach unten links
                     else if (Left=8) AND (Top>56) then Top :=Top-90;//unten links nach oben links
end;

begin
  FMono.Edit1.Text:=IntToStr(wurf(AnzahlWurfel));
   Lefti:=Spieler.Left;
   Topi:=Spieler.Top;
  gehen(wurf(AnzahlWurfel),Lefti,Topi);
   Spieler.Left:=Lefti;
   Spieler.Top:=Topi;
end;
Neubauer
  • 21
  • 5
  • 1
    Unit2 needs to USE which unit your TImage is declared in. In Delphi the unit to use would be ExtCtrls.Pas – MartynA Jul 04 '17 at 21:58

1 Answers1

1

Solution is typing the uses before the procedure and in the interface.

interface

uses
 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ActnList, ExtCtrls, u_settings, u_grafik;

procedure Bewegen(Spieler:TImage);
Neubauer
  • 21
  • 5