AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

java to delphi

Ein Thema von pastra · begonnen am 26. Feb 2009 · letzter Beitrag vom 26. Feb 2009
Antwort Antwort
pastra

Registriert seit: 23. Jun 2006
21 Beiträge
 
#1

java to delphi

  Alt 26. Feb 2009, 02:50
I am trying to translate this java code to delphi:

Delphi-Quellcode:
String FlashG(int fromINT, int toINT)
    {
        StringBuffer stringbuffer = new StringBuffer();
        int PPP;
        for(PPP = toINT; PPP < fromINT; PPP *= toINT);
        do
        {
            int OOP = fromINT / PPP;
            char COMP = (char)(LEVEL + OOP);
            stringbuffer.append(COMP);
            fromINT -= PPP * OOP;
            PPP /= toINT;
        }
 while(PPP > 0);
        return stringbuffer.toString();
    }


LEVEL = 'K';

It goes fine to the point of the for loop. Can't figure it out.. PPP is changed in the for loop?

If anyone can translate it, it will be greatly appreciated.

Cheers


Regards PasTra
  Mit Zitat antworten Zitat
Benutzerbild von jaenicke
jaenicke

Registriert seit: 10. Jun 2003
Ort: Berlin
9.332 Beiträge
 
Delphi 11 Alexandria
 
#2

Re: java to delphi

  Alt 26. Feb 2009, 03:11
As you didn't tell what the code is for I couldn't test it. A direct translation should be:
Delphi-Quellcode:
function FlashG(fromINT, toINT: Integer): String;
var
  PPP, OOP: Integer;
begin
  Result := '';
  PPP := toINT;
  while PPP < fromInt do
    PPP := PPP * toINT;
  repeat
    OOP := fromInt div PPP;
    Result := Result + Chr(Ord('K') + OOP);
    fromInt := fromInt - PPP * OOP;
    PPP := PPP div toInt;
  until PPP <= 0;
end;
The naming conventions are different in Delphi but I didn't change it.
Sebastian Jänicke
Alle eigenen Projekte sind eingestellt, ebenso meine Homepage, Downloadlinks usw. im Forum bleiben aktiv!
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:24 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz