Autor Beitrag
1aa
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47
Erhaltene Danke: 1

Win Vista, Win8
Delphi 2007
BeitragVerfasst: Mi 04.06.08 22:29 
Ich habe die folgende Procedure geschrieben und das Programm gestartet doch Delphi ignoriert die 1. und die letzte Anweisung im Quelltext!

Woran könnte das liegen?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.GR(erg:integer;C1:TCheckBox;E1:TEdit;C2:TCheckBox;E2:TEdit;C3:TCheckBox;E3:TEdit;C4:TCheckBox;E4:TEdit);
var summe:integer;
Begin
summe:=0;
if c1.Checked then summe:=summe+strtoint(E1.Text);
if c2.Checked then sum:=sum+strtoint(E2.Text);
if c3.Checked then sum:=sum+strtoint(E3.Text);
if c4.Checked then sum:=sum+strtoint(E4.Text);
erg:=summe;
End;



Moderiert von user profile iconNarses: Topic aus Algorithmen, Optimierung und Assembler verschoben am Mi 04.06.2008 um 23:33
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Mi 04.06.08 22:34 
Versuch mal

ausblenden Delphi-Quelltext
1:
procedure TForm1.GR(var erg:integer;C1:TCheckBox;E1:TEdit;C2:TCheckBox;E2:TEdit;C3:TCheckBox;E3:TEdit;C4:TCheckBox;E4:TEdit);					


Btw: Hat das einen Grund, dass du sonst nur noch mit Sum arbeitest?
1aa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47
Erhaltene Danke: 1

Win Vista, Win8
Delphi 2007
BeitragVerfasst: Mi 04.06.08 22:56 
danke jetz gehts

lag an "var"
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Mi 04.06.08 23:08 
Vielleicht noch kurz zur Erklärung, wieso und weshalb:

"var" sorgt dafür, dass die Prozedur die Variable ändern kann, und diese Änderung auch in der aufrufenden Prozedur wirksam wird.
Weil das nicht da stand, hat der Compiler manche Zeilen weg-optimiert, da sie dann keinen Sinn gehabt hätten.
1aa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47
Erhaltene Danke: 1

Win Vista, Win8
Delphi 2007
BeitragVerfasst: Do 05.06.08 21:49 
ICh weis...
hinterher is es mir auch wieder eingefallen...
Trotzdem danke für die schnelle Hilfe