String

This is an old revision of String, edited by FPC user at . The current revision is 32238.

note $mode setting effect on string alias, alias instead of synonym, length edit

String is a type which may contain characters.

Alias

String is an alias for ShortString or AnsiString depending on the current compiler setting.

If compiler directive {$H} or compiler directive {$LongStrings} is on ( {$H+} or {$LongStrings ON} ), then a String type is the same as an AnsiString type, if not ( {$H-} or {$LongStrings OFF} ), it is a ShortString type. What String is an alias for can also be set by the -Sh command line option.

NOTE: The {$mode} compiler directive has an effect on the current setting for which type a String is an alias to. After the compiler mode is set to FPC, ObjFPC, MacPAS or TP, String will be an alias for ShortString. After the compiler mode is set to Delphi, String will be an alias for AnsiString. You can override the String setting of a particular mode by following the {$mode} directive with a compiler directive to set the String alias:

{$mode ObjFPC}   // String is an alias for ShortString
{$H+}            // String is now an alias for AnsiString

ShortString/AnsiString

The potential alias types for type String - ShortString and AnsiString - differ with respect to length:

See also

navigation bar: data types

simple data types boolean byte cardinal char currency double dword extended int8 int16 int32 int64 integer longint real shortint single smallint pointer qword word
complex data types array class object record set string shortstring