Autor Beitrag
Jakob_Ullmann
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Mi 22.10.08 16:28 
Hallo.

Scheinbar bekommt die PascalScript beim Rechnen von 3/2 = 1 heraus. Bei einer Double-Variable. Ich hab das so gemacht, wie es hier beschrieben steht:

der Code sieht also so aus:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
      PSScript1.Script.Text :=
               'var ' +
                 'X: Double; ' +
               'begin ' +
                 'X := ' + expression + '; ' +
                 'GetResult(X); ' +
              'end. ';


Was ist da faul? Irgendwas muss ja faul sein, denn bei 3/2-1.5 als Expression kommt -1.5 heraus. :wink:

EDIT: Und bei 10/3 kommt 3 heraus. Bei 10/3.0 dagegen 3.33333 - kann man das der PascalScript nicht irgendwie abgewöhnen? Für sowas gibt es doch "div"...
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mi 22.10.08 16:55 
Ich glaub, ich hab ein Déjà-vu... Crosspost.
Jakob_Ullmann Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Mi 22.10.08 17:12 
Ich hab das Problem jetzt gelöst, durch Zusatz von RegExpr. :mrgreen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
      RE := TRegExpr.Create;
      ...
      RE.Expression := '([0-9]*)';
      expression := RE.Replace(expression, '$1.', True);
      expression := StringReplace(expression, '..', '.', [rfReplaceAll]);
      ...
      RE.Free;


Weiß zwar nicht, wieso da dann 3.. und nicht 3. stand, aber hauptsache es funktioniert. :angel: