Autor Beitrag
Christoph Englmann
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 276



BeitragVerfasst: Mi 04.08.04 12:30 
HAllo,

bin absoluter neuling und folgenden Code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
//Tagesbezeichnung ermitteln
Guelt_Day_Bez[1] := Wochentag(Guelt_Day[1]);

function Wochentag(t :string): string;
  begin
    if Tag = '1' then Result := 'Montag';
  end


wie zu sehen ist, will ich einfach nur die funktion Wochentag aufrufen....
der compiler meldet den Fehler undefinierter Bezeichner wochentag...

wo bzw. wie muss ich die funktion noch deklarieren oder so...
(das beispiel steht im prinzip so in meinem delphi buch :-(

danke

christoph
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Mi 04.08.04 12:43 
Hallo!

Du musst Funktionen entweder vor der Stelle, wo du sie nutzt, implementieren, oder du deklarierst die Funktion zunächst im interface-Teil, also:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
unit MeineUnit;

interface

...

function Wochentag(t :string): string;  

implementation

...

function Wochentag(t :string): string;  
begin  
  if Tag = '1' then Result := 'Montag';  
end 

...

end.


Cu,
Udontknow
Christoph Englmann Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 276



BeitragVerfasst: Mi 04.08.04 15:16 
Hallo,

danke erstmal, wenn ich das so mache mit der deklaration, dann erscheint folgende Fehlermeldung:
"Ungenügende Forward oder External Deklaration TformBT.Wochentag....

christoph
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 04.08.04 15:19 
Wenn du die Funktion in der Klasse "angibst", dann musst du sie logischerweise auch als Methode deiner Form-Klasse implementieren.
Christoph Englmann Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 276



BeitragVerfasst: Mi 04.08.04 17:26 
Danke jetzt klappts auch mit dem compilieren, allerdings übergibt die Funktion das Result nicht an die Variabble test...
(die If bedinung funzt, aber test hat nach durchlauf den Wert '')


ausblenden 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:
procedure TFormBT.cboTGL_2Change(Sender: TObject);

function Wochentag(Tag :string): string;
  begin
    if Tag = '1' then
      begin
        Result := 'Montag'
      end;
  end;

type TGuelt_Day = array[1..50] of string;

var
  i :integer;
  Guelt_Day :TGuelt_Day;
  Guelt_Day_Bez :TGuelt_Day;
  test : string;


//Tagesbezeichnung ermitteln
begin
  test := Wochentag(Guelt_Day[1]);
end;



christoph