Top  Previous  Next

What is translated > Indexes > ZEROBASEDSTRINGS

Sometimes a ZEROBASEDSTRINGS directive is used in Delphi code. by which the local string indexing is changed. For example in front of the implementation code of TStringHelper the directie is set on:





The following is a code example from Embarcadero, which demonstrates, how to use the Char-property of TStringHelper:




  I: Integer;

  MyString: String;



  MyString := 'This is a string.';


  for I:= 0 to MyString.Length - 1 do





The individual characters of the string are accessed here via a zero based index.


The automatic translation of the TStringHelper code doesn't regard the ZEROBASEDSTRINGS directive. Therefore - if zero based target strings are chosen - the translator inserts a wrong correction for the String m_Helped member. E.g.


  result = m_Helped[Index - 1];


This correction has to be removed manually:


  result = m_Helped[Index];



If return values of functions, which are used inside of  sections of code where ZEROBASEDSTRINGS is ON, depend on the assumption of one based strings, these values have to be corrected too. the function Low and High are such typical candidates. E.g.








This page belongs to the Delphi2Cpp Documentation

Delphi2Cpp home  Content