Autor Beitrag
miroh
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Do 10.02.05 19:52 
hab kaum ahnung von delphi bzw. pascal und hab ein problem!
ich hab eine verzweigung geschrieben...

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 TForm1.B_RatenClick(Sender: TObject);
begin
  v_Eingabe := StrToInt(E_Eingabe.Text);
  IF v_Eingabe < v_zahl
  THEN
        BEGIN
  P_Ausgabe.Caption := 'zu klein';
        END
  ELSE
        BEGIN
  IF v_Eingabe = v_zahl
  THEN
        BEGIN
  P_Ausgabe.Caption := 'Richtig';
        END
  ELSE
        BEGIN
  P_Ausgabe.Caption := 'zu groß';
        END;


end;
end.


...und tauchen folgende fehlermeldungen auf...

[Fehler]U_Zahlenraten.pas(77):';' erwartet, aber '.' gefunden
[Fehler]U_Zahlenraten.pas(86):Deklaration erwartet, aber Dateiende gefunden

...und das letzte end, also 'end.' ist markiert!
was kann ich tun?
hoffe jemand kann mir helfen :wink:
jetzt schon mal DANKE!!!

Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt.
Moderiert von user profile iconTino: Topic aus Sonstiges verschoben am Fr 11.02.2005 um 10:35
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Do 10.02.05 19:54 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm1.B_RatenClick(Sender: TObject); 
begin 
  v_Eingabe := StrToInt(E_Eingabe.Text); 
  IF v_Eingabe < v_zahl 
  THEN 
    P_Ausgabe.Caption := 'zu klein'
  ELSE 
    IF v_Eingabe = v_zahl 
  THEN 
    P_Ausgabe.Caption := 'Richtig'
  ELSE 
    P_Ausgabe.Caption := 'zu groß'
END;


so müsste es stimmen :roll: jedenfalls vom syntax her :wink:


Zuletzt bearbeitet von F34r0fTh3D4rk am Do 10.02.05 19:55, insgesamt 1-mal bearbeitet
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Do 10.02.05 19:55 
Ein END zuviel. Da dein Code aber furchtbar formatiert ist kann ich dir nichtmal sagen, welches END

AXMD
miroh Threadstarter
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Do 10.02.05 19:57 
vielen dank noch ma
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Do 10.02.05 19:58 
geht es ?

Zitat:

Ein END zuviel. Da dein Code aber furchtbar formatiert ist kann ich dir nichtmal sagen, welches END

normal doch zu wenig oder? wenn ":" erwartet wird ?

ja die begins und ends werden eh nich gebraucht, verwirrt nur unnötig
der_zaehe
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 317

WinXP SP2
D6 Pers, D2005 Prof, VS2005
BeitragVerfasst: Do 10.02.05 20:44 
mein tip für dich ist, falls so ein problem noch mal auftauchen sollte, den quelltext vernünftig zu formatieren, etwa so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
  if Boolean1 = TRUE then
  begin
    //hier einrücken
  end
  else
  begin
    //hier einrücken
  end;

_________________
[inspirationslos]


Zuletzt bearbeitet von der_zaehe am Do 10.02.05 23:17, insgesamt 1-mal bearbeitet
patrick
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1481

WIN2k, WIN XP
D6 Personal, D2005 PE
BeitragVerfasst: Do 10.02.05 21:10 
F34r0fTh3D4rk hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm1.B_RatenClick(Sender: TObject); 
begin 
  v_Eingabe := StrToInt(E_Eingabe.Text); 
  IF v_Eingabe < v_zahl 
  THEN 
    P_Ausgabe.Caption := 'zu klein'
  ELSE 
    IF v_Eingabe = v_zahl 
  THEN 
    P_Ausgabe.Caption := 'Richtig'
  ELSE 
    P_Ausgabe.Caption := 'zu groß'
END;


so müsste es stimmen :roll: jedenfalls vom syntax her :wink:



nö, eben nicht.
ein ; vor einer else ist nämlich verboten.
außerdem fehlt dir in der tat ein end;, weil es 2 if verzweigungen in der prozedur gibt, aber nur eine mit end; abgeschlossen wurde.

hier mal mein vorschlag (inkl anderer formatierung):
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
procedure TForm1.B_RatenClick(Sender: TObject);   
begin
  v_Eingabe := StrToInt(E_Eingabe.Text);
  if v_Eingabe < v_zahl then
  begin
    P_Ausgabe.Caption := 'zu klein';
  end
  else
  begin
    if v_Eingabe = v_zahl then
    begin
      P_Ausgabe.Caption := 'Richtig';
    end
    else
    begin
      P_Ausgabe.Caption := 'zu groß';
    end;
  end;
end;

abgesehen das ich solche sachen wie v_Zahl in VZahl bzw nen ausdruckstärkeren variablennamen benutzen. das ist aber jetzt absolut mein style ^^.

am übersichtlichsten lässt sich solcher code aber so schreiben:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
procedure TForm1.B_RatenClick(Sender: TObject); 
begin
  v_Eingabe := StrToInt(E_Eingabe.Text);

  if v_Eingabe < v_zahl then
  begin
    P_Ausgabe.Caption := 'zu klein';
  end;

  if v_Eingabe = v_zahl then
  begin
    P_Ausgabe.Caption := 'Richtig';
  end;

  if v_Eingabe > v_zahl then
  begin
      P_Ausgabe.Caption := 'zu groß';
  end;
end;

_________________
Patrick
im zweifelsfall immer das richtige tun!!!
CenBells
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1547

Win 7
Delphi XE5 Pro
BeitragVerfasst: Fr 11.02.05 11:19 
patrick hat folgendes geschrieben:
F34r0fTh3D4rk hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm1.B_RatenClick(Sender: TObject); 
begin 
  v_Eingabe := StrToInt(E_Eingabe.Text); 
  IF v_Eingabe < v_zahl 
  THEN 
    P_Ausgabe.Caption := 'zu klein'
  ELSE 
    IF v_Eingabe = v_zahl 
  THEN 
    P_Ausgabe.Caption := 'Richtig'
  ELSE 
    P_Ausgabe.Caption := 'zu groß'
END;


so müsste es stimmen :roll: jedenfalls vom syntax her :wink:



nö, eben nicht.
ein ; vor einer else ist nämlich verboten.
außerdem fehlt dir in der tat ein end;, weil es 2 if verzweigungen in der prozedur gibt, aber nur eine mit end; abgeschlossen wurde....

Hi,

was meinst du, welches End der Father denn überhaupt noch hingeschrieben hat? das prozedur end; . Man braucht in dem hier diskutierten code definitiv kein begin und end in jedem if then else block.

Also, nochmal die korrigierte Fassung ( ; ) ;)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.B_RatenClick(Sender: TObject); 
begin 
  v_Eingabe := StrToInt(E_Eingabe.Text); 
  IF v_Eingabe < v_zahl THEN 
    P_Ausgabe.Caption := 'zu klein'
  ELSE IF v_Eingabe = v_zahl THEN 
    P_Ausgabe.Caption := 'Richtig'
  ELSE 
    P_Ausgabe.Caption := 'zu groß'
END;


Gruß
Ken

_________________
Eine Klasse beschreibt die Struktur und das Verhalten einer Menge gleichartiger Objekte.
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Fr 11.02.05 16:02 
ohh da hab ich garnet drauf geachtet, hast natürlich recht, das ist übelst verboten !