ZEROBASEDSTRINGS |
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:
{$ZEROBASEDSTRINGS ON}
The following is a code example from Embarcadero, which demonstrates, how to use the Char-property of TStringHelper:
var I: Integer; MyString: String;
begin MyString := 'This is a string.';
for I:= 0 to MyString.Length - 1 do Write(MyString.Chars[I]); end.
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 DelphiXE2Cpp11 Documentation |
DelphiXE2Cpp11 home Content |