Autor Beitrag
rizor
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: Sa 06.01.07 13:12 
Hallo,

mein Matheparser macht was er will.

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:
24:
25:
26:
27:
28:
procedure TParser.FormatierungMain;
  var
    PotenzZahl , i : integer;
    ArrayTeil : TStringList;
begin
  if (byArray[byZaehler][byArrayLaenge] = 'x') and (byArrayLaenge > 1) then
    byArray[byZaehler] := byArray[byZaehler] + '^1';
  ArrayTeil := TStringList.Create;
  ArrayTeil.Delimiter := '^';
  ArrayTeil.DelimitedText := byArray[byZaehler];
  if ArrayTeil.Count >= 2 then
  begin
    for i := 1 to length(ArrayTeil[0]) do
    begin
      if ArrayTeil.Strings[0][i]<>'x' then
        byBasis := byBasis + ArrayTeil.Strings[0][i];
    end;
    PotenzZahl := StrToInt(ArrayTeil.Strings[1]);
    for i := 1 to PotenzZahl do
    begin
      if (byBasis = '') and (byPotenz = '') then
        byPotenz := 'x'
      else
        byPotenz := byPotenz + '*x';
    end;
    ArrayTeil.Free;
  end;
end;


Das ist die Unit, die alles umschreibt, damit ich damit rechnen kann.

Die Hauptunit ist folgende:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TParser.Formatierung;
  var i : integer;
begin
  for i := 0 to byArrayPos do
  begin
    byZaehler := i;
    byBasis := '';
    byPotenz := '';
    byArrayLaenge := length(byArray[i]);
    FormatierungMain;
    byArray[i] := byBasis + byPotenz;
  end;
end;


Die variablen sind wie folgt definiert:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
type TParser = class(TObject)
  private
    byBasis,
    byPotenz,
    byWert : string;
    byLaenge,
    byZaehler,
    byArrayLaenge,
    byArrayMenge,
    byArrayPos : Integer;
    procedure AufteilungMain;
    procedure FormatierungMain;
  public
    byArray: array of string;
    procedure Vorbereitung;
    procedure Aufteilung;
    procedure Formatierung;
end;


Wenn ich nun 12x^2 eingebe gibt er mir 12x^1^2 aus und wenn ich 12x eingebe kommt richtiger weise 12x^1 bei raus.
Das problem ist, dass er nach der Formatierung von 12x bzw. 12x^2 nicht mehr weiter arbeitet.
Eigentlich müsste er 12x^1^2 in 12+x umformatierun, dass tut er aber net.

Wieso?
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Sa 06.01.07 14:24 
Weil du es so programmiert hast.

Wenn du mit dem Debugger Schritt für Schritt durch den Code gehst wirst du schlauer.
rizor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: Sa 06.01.07 15:01 
hmm...
Manchml bin ich echt vernagelt...
Danke.
Jetstream
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 222



BeitragVerfasst: Sa 06.01.07 15:09 
user profile iconrizor hat folgendes geschrieben:
Eigentlich müsste er 12x^1^2 in 12+x umformatierun


Verstehe die Rechnung nicht.

_________________
Die folgenden Klangbeispiele sind Ergänzungen zum methodischen Aufbau der Textbeilage und dürfen nicht losgelöst von dieser behandelt werden.
rizor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: Sa 06.01.07 18:30 
Hab mich verschrieben.
Sollte 12*x heißen.