Autor Beitrag
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Mi 21.09.05 21:31 
Also ich habe einen Taschenrechner geschrieben, und habe das Problem, wenn ich z.B. 4+2=6 rechne und dann nochmals "Ergebnis" drücke, rechnet er nicht 6+2 weiter, was ja jeder normale Taschenrechner auch macht, sondern 6+4 (Zahl1).

Ich weiß zwar wo mein Fehler ist, weiß aber nicht, wie ich es sonst ausdrücken soll.
Ich hänge das Projekt einfach mal an, dann könnt ihr ihn euch ansehen :)

greetz

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 22.09.05 00:39 
Hallo!

Du solltest die relevanten (und nur diese) Passagen aus dem Quelltext hier posten. Den meisten wird es wohl zu umständlich sein, sich das selber zu suchen. Das strapaziert die Hilfsbereitschaft schon ziemlich, auch wenn es Deine Arbeit an Deinem Problem minimiert.

Grüße
Christian

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Born-to-Frag Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Do 22.09.05 12:48 
Na gut :) .. hier also mal ein Ausschnitt

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:
var
  Form1: TForm1;
  Zahl1, Zahl2 : real;
  opcode : char;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  if Ausgabe.Text = '0' then
    Ausgabe.Text := '1'
    else Ausgabe.Text := Ausgabe.Text + '1';
end;

procedure TForm1.ButtonPlusClick(Sender: TObject);
begin
  opCode := '+';
  Zahl1 := StrToFloat(Ausgabe.Text);
  Ausgabe.Text := '0';
end;

procedure TForm1.ErgebnisClick(Sender: TObject);
begin
  Zahl2 := StrToFloat(Ausgabe.Text);
  if opcode = '+' then
    Ausgabe.Text := FloatToStr(Zahl1 + Zahl2);
  if opcode = '-' then
    Ausgabe.Text := FloatToStr(Zahl1 - Zahl2);
  if opcode = '*' then
    Ausgabe.Text := FloatToStr(Zahl1 * Zahl2);
  if opcode = '/' then
    Ausgabe.Text := FloatToStr(Zahl1 / Zahl2);
end;


Also das ist jetzt ein kleiner Ausschnitt, einmal mit der Zahl1, und mit einem Rechenzeichen und mit Ergebnis.

greetz

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 22.09.05 13:32 
Moin!

Sorry, aber IMHO ist das mit deinem Programmkonzept nicht realisierbar. :|

Such mal nach "calc-stack" oder "calculator stack" im Internet, mit so einem Ansatz kommste weiter. Könnte aber nicht ganz trivial sein... :wink:

cu
Narses
Born-to-Frag Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Do 22.09.05 15:05 
Naja, macht auch nix.. Trotzdem danke Narres..

greetz









erm.. ich meine natürlich N-A-R-S-E-S :P:P:P

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
AG
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Do 22.09.05 15:44 
doch, geht schon;
setzt ein Flag, das am Anfang 0 ist (so ne Art Zähler für '=' gedrückt - kannst auch einen Boolean-Wert nehmen)

- wenn '=' gedrückt wird, und das Flag 0 ist, setzt du das Flag auf 1, und rechnest wie bisher
- wenn '=' gedrückt wird, und das Flag 1 ist,
liest du den Wert im Edit-Feld in Zahl1 ein, und rechnest wie bisher
- wenn +-*/ gedrückt wird, setzt du das Flag wieder auf 0

das sollte eigentlich klappen...
Born-to-Frag Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Do 22.09.05 16:21 
Mhhh... STIMMT!! ES HAT GEKLAPPT!!! DANKE DANKE DANKE DANKE

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 22.09.05 21:57 
Moin!

Oh, stimmt :? hab zu kompliziert gedacht und mich vom Programmierstil ablenken lassen... :| Sorry.

cu
Narses