Zero-based strings (Delphi)

From RAD Studio
Jump to: navigation, search

Go Up to Delphi Compiler Directives (List) Index


Type

Switch

Syntax

{$ZEROBASEDSTRINGS ON} or {$ZEROBASEDSTRINGS OFF}

Default

{$ZEROBASEDSTRINGS ON} for Delphi mobile compilers
{$ZEROBASEDSTRINGS OFF} for Delphi desktop compilers

Scope

Local


Remarks

{$ZEROBASEDSTRINGS} controls the indexing used locally for string types:

  • {$ZEROBASEDSTRINGS OFF} is the default for the Delphi desktop compilers (DCC32, DCC64, DCCOSX, DCCLINUX64), which use 1-based indexing for strings.
  • $ZEROBASEDSTRINGS ON} is the default for the Delphi mobile compilers (DCCIOSARM, DCCIOS32), which use 0-based indexing for strings.
Caution: You can use {$ZEROBASEDSTRINGS} to change the local string indexing scheme. For example, in a Delphi application for mobile platforms, you can define {$ZEROBASEDSTRINGS OFF} to change to 1-based string indexing.
For example, {$ZEROBASEDSTRINGS} is useful if you have an isolated instance of in-place string editing that you cannot revise at the moment.
However, the mobile compilers and the RTL for the Delphi mobile use 0-based strings by default, so you must use 0-based strings when you are using the RTL in Delphi applications for mobile platforms.
Do not define {$ZEROBASEDSTRINGS} in mobile code larger than a snippet. Results would be unpredictable for an entire module or application for mobile platforms.

See Also