![]() |
Re: HELP: JAVA TO PASCAL/DELPHI
Hi s.h.a.r.k!
Thanks for translating the code, I am about to test it now.... You wrote: j := 1; // Index in a String is different - in Delphi it starts with 1 i fixed it like this: while j <= i do otherwise the last char didn't get processed.. I will return later and tell you how it is going.. For now BIG thanks and by the way, I really think this forum "ROX" Chears Pastra |
Re: Java to pascal/delphi
Zitat:
|
Re: Java to pascal/delphi
Hi,
I think there are some little mistakes you should fix. First of all, you don't need any kind of StringBuffer in Delphi. To Java a String is just a static class and each assignment will create a new instance (and the GC have to free the old unused one). Therefore a buffer (no fixed size) encapsulates the functianality of working with strings that are supposed to change there size. Although this is next to the Delphi-behaviour working with Strings you know how many characters are used in your string and you can allocate this memory before returning the string (of cause you can use the TStringList, but no need to do so!) Lets have a look at this part
Delphi-Quellcode:
Well there is something missing, don't you think? Although k is changed, no one will ever know. And Java does automaticaly cast a single Character into a short value, that does not mean, that the string will be casted into the represented value (StrToInt) but the byte value of this string (e.g. A = 65).
if c = '&' then
begin if (i < j+5) then begin break; end; k := 0; for l := 0 to 3 do begin inc(j); k := k*16; k := k + StrToInt(s[j]) - 65; // Here you habe to be careful! The character here must be a number! end; end Just change the sourcelines to
Delphi-Quellcode:
Regards Der Unwissende
if c = '&' then
begin if (i < j+5) then begin break; end; k := 0; for l := 0 to 3 do begin inc(j); k := k*16; k := k + ord(s[j]) - 65; // Here you habe to be careful! The character here must be a number! end; buffer.append(chr(k)); end |
Re: Java to pascal/delphi
Hi again, thanks it works now. Yes I see what you meen by + ord(s[j])..
Thanks! |
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:55 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz