Autor Beitrag
wicked
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Do 31.07.08 11:25 
Hallo,

ich habe ein programm geschrieben, was zur berechnung der fläche und des umfangs eines dreiecks eine prozedur benutzt.. leider kommt, wenn ich das programm starten will die fehlermeldung "ungenügende forward- oder externaldeklaration: 'TForm1.Dreieck'"
kann mir jemand sagen, was ich flasch gemacht habe?

hier der quelltext:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    aEdit: TEdit;
    bEdit: TEdit;
    cEdit: TEdit;
    FlaecheEdit: TEdit;
    UmfangEdit: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;

    RechnenButton: TButton;
    AbbruchButton: TButton;
    procedure AbbruchButtonClick(Sender: TObject);
    procedure Dreieck(a,b,c:Real;var Umfang,Flaeche:Real);
    procedure RechnenButtonClick(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.AbbruchButtonClick(Sender: TObject);
begin
  Close;
end;

procedure TForm1.RechnenButtonClick(Sender: TObject);
var a,b,c,Flaeche,Umfang: Real;
begin
  a:=StrToFloat(aEdit.Text);
  b:=StrToFloat(bEdit.Text);
  c:=StrToFloat(cEdit.Text);
  Dreieck(a,b,c,Flaeche,Umfang);
  FlaecheEdit.Text:=FloatToStr(Flaeche);
  UmfangEdit.Text:=FloatToStr(Umfang);
end;

procedure Dreieck (a,b,c:Real;var FLaeche,Umfang:Real);
var s : Real;
begin
  Umfang:=a+b+c;
  s:=Umfang/2;
  Flaeche:=Sqrt(s*(s-a)*(s-b)*(s-c));
end;

end.


Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt
nagel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 708

Win7, Ubuntu 10.10

BeitragVerfasst: Do 31.07.08 11:54 
TForm1 davor:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Dreieck (a,b,c:Real;var FLaeche,Umfang:Real);
var s : Real;
begin
...
wicked Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Do 31.07.08 12:55 
hm das hab ich jetzt gemacht, aber nun kommt die fehlermeldung "delaration von 'dreieck' unterscheidet sich von vorheriger deklaration"... komisch
hazard999
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 162

Win XP SP2
VS 2010 Ultimate, CC.Net, Unity, Pex, Moles, DevExpress eXpress App
BeitragVerfasst: Do 31.07.08 13:13 
1. Dreieck gehört nach private

2. procedure Dreieck(a,b,c:Real;var Umfang,Flaeche:Real); ist ungleich
procedure Dreieck (a,b,c:Real;var FLaeche,Umfang:Real);

PS: HasA ist zwar auch erlaubt, hat aber die sichtbarkeit public

_________________
MOV EAX, Result;MOV BYTE PTR [EAX], $B9;MOV ECX, M.Data;MOV DWORD PTR [EAX+$1], ECX;MOV BYTE PTR [EAX+$5], $5A;MOV BYTE PTR [EAX+$6], $51;MOV BYTE PTR [EAX+$7], $52;MOV BYTE PTR [EAX+$8], $B9;MOV ECX, M.Code;MOV DWORD PTR [EAX+$9], ECX
hazard999
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 162

Win XP SP2
VS 2010 Ultimate, CC.Net, Unity, Pex, Moles, DevExpress eXpress App
BeitragVerfasst: Do 31.07.08 13:24 
3. Eingabe von etwas das keine Zahl ist führt zu einer Fehlermeldung.
StrToFloat durch StrToFloatDef ersetzten und sinnvollen Default wählen (0 oder < 0)
Ergebnis prüfen

4. Eingabe von negativen Zahlen können zu keinem sinnvollen Ergebnis führen.

_________________
MOV EAX, Result;MOV BYTE PTR [EAX], $B9;MOV ECX, M.Data;MOV DWORD PTR [EAX+$1], ECX;MOV BYTE PTR [EAX+$5], $5A;MOV BYTE PTR [EAX+$6], $51;MOV BYTE PTR [EAX+$7], $52;MOV BYTE PTR [EAX+$8], $B9;MOV ECX, M.Code;MOV DWORD PTR [EAX+$9], ECX
hazard999
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 162

Win XP SP2
VS 2010 Ultimate, CC.Net, Unity, Pex, Moles, DevExpress eXpress App
BeitragVerfasst: Do 31.07.08 13:29 
5. Eingabe von 1,7E308 führt zu einer EOverflow-Exception in der Berechnung

_________________
MOV EAX, Result;MOV BYTE PTR [EAX], $B9;MOV ECX, M.Data;MOV DWORD PTR [EAX+$1], ECX;MOV BYTE PTR [EAX+$5], $5A;MOV BYTE PTR [EAX+$6], $51;MOV BYTE PTR [EAX+$7], $52;MOV BYTE PTR [EAX+$8], $B9;MOV ECX, M.Code;MOV DWORD PTR [EAX+$9], ECX
Jerk
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 251

Vista Ultimate, Ubuntu
Turbo Delphi 2006
BeitragVerfasst: Do 31.07.08 16:14 
user profile iconwicked hat folgendes geschrieben:
hm das hab ich jetzt gemacht, aber nun kommt die fehlermeldung "delaration von 'dreieck' unterscheidet sich von vorheriger deklaration"... komisch



nur im implementation Teil muss TForm1. davor "oben" bleibt es so wie es isst.