Autor Beitrag
DrRzf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 260

Win XP Prof
D7 Enterprise
BeitragVerfasst: Mo 27.03.06 18:10 
ich versuche grad eine berechnung die in PHP programmiert wurde in delphi umzusetzen.
dabei hab ich folgendes problem.

hier erstmal der PHP code.
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
public function basiszeit()
  {
    // testet ob es der GLEICHE PLANET ist
    if( ($this->sx == $this->zx) && ($this->sy == $this->zy) && ($this->sz == $this->zz) )
    {
      $return = 640000 * 0.5;
    }
    else
    {
      $distance = $this->distance();
      $flugzeit = 60*($distance/5+1);
      // testet ob es ein HORIZONTALER/VERTIKALER FLUG ist
      if( ($this->sx != $this->zx) || ($this->sy != $this->zy) ) //<--- wie setz ich das um ?
      {
        $flugzeit += 30;
      }
      $distance_2d = $this->distance_2d();
      $flugzeit = $flugzeit-($distance_2d*8);
      echo "flugzeit nach d2d*8: $flugzeit\n"; //<--- hier fehlen dann die 30 beim debuggen in delphi
      $return = $flugzeit * 640000;
    }
  return $return;


und hier das was ich in delphi gecodet hab.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
function GetBasisZeit(Sx,Sy,Sz,Zx,Zy,Zz : integer): real;
var
  dis,fz, d2d : real;
begin
  if (Sx = Zx) and (Sy = Zy) and (Sx = Zx) then  
    result := 320000
    else
    begin
      dis := Get3DDist(Sx,Sy,Sz,Zx,Zy,Zz);
      fz := 60*(dis/5 + 1);
      if  (Sx = Zx) or (Sy = Zy) then  //<--- hier das problem
        fz := fz + 30;
      d2d := Get2DDist(Sx,Sy,Zx,Zy);
      fz := fz - (d2d * 8);
      result := fz * 640000;
    end;
end;


mein problem liegt nun an dieser zeile
if( ($this->sx != $this->zx) || ($this->sy != $this->zy) )

hab es in delphi so umgesetzt
if (Sx = Zx) or (Sy = Zy) then

aber hier scheint etwas nicht mit dem or nicht hinzuhauen da mir nach der berechnung bei fz die 30 im php code addiert werden, im delphi code aber nicht. die werte sx,zx und sy,zy sind unterschiedlich.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mo 27.03.06 18:14 
Im PHP-Code wird doch auf Ungleichheit (!=) geprüft, im Delphi-Quelltext auf Gleichheit (=) :gruebel:

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Sirke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 208
Erhaltene Danke: 2



BeitragVerfasst: Mo 27.03.06 18:14 
Das Zeichen != in der If-Anweisung in PHP bedeutet ungleich und sieht in Delphi so aus: <>, sodass du den Code in if (Sx <> Zx) or (Sy <> Zy) then ändern musst.
DrRzf Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 260

Win XP Prof
D7 Enterprise
BeitragVerfasst: Mo 27.03.06 18:20 
vielen dank für die schnelle hilfe.
jetzt klappts.