Einzelnen Beitrag anzeigen

WojTec

Registriert seit: 17. Mai 2007
482 Beiträge
 
Delphi XE6 Professional
 
#1

For-loop from C to Delphi

  Alt 18. Sep 2011, 17:13
Delphi-Version: 5
Could you help translate this:

Code:
   for (i = 0; i < temp_length; i += 2)
   {
      if(temp[i] == 'X') {
         strcpy(symbol->errtxt, "Invalid position of X in Telepen data");
         return ZERROR_INVALID_DATA;
      }
      
      if(temp[i + 1] == 'X') {
         glyph = ctoi(temp[i]) + 17;
         count += glyph;
      } else {
         glyph = (10 * ctoi(temp[i])) + ctoi(temp[i + 1]);
         glyph += 27;
         count += glyph;
      }
   }
to something that can be understable for me (Delphi). I tried (but I know is bad):

Delphi-Quellcode:
  for I := 1 to Length(Data) do
  begin
    if Ord(Data[I + 1]) = 88 then
      Count := Count + StrToInt(Data[I]) + 17
    else
      Count := Count + (10 * StrToInt(Data[i])) + StrToInt(Data[i + 1]) + 17
    ;
  end;
  Mit Zitat antworten Zitat