The String data type is used to hold sequences of characters, like sentences.
String is by default, actually treated as a AnsiString. It can be treated as a ShortString if the $LongStrings compiler directive is set Off (the default is On).
An AnsiChar can hold any number of characters, restricted only by memory.
Version 2 however, forces the string to be a ShortString by defining a FixedSize (up to 255 characters) of the string. This is particularly important when creating many strings, and especially so when storing strings in records (as in example 2).
Strings can be assigned from other strings, from functions that return a string, and with concatenations as in the sample code.
Strings are indexed with 1 for the first character (arrays start with 0 for the first element).
Example code : Assigning to a string and then adding a bit more
myString : String;
begin // Assign a famous sentence to this string
myString := 'Hello World'; // Add to this string
myString := myString + ', how is everyone?'; // Display the final myString value
ShowMessage('myString = '+myString);
Example code : Using fixed length strings in a record
type // Declare a customer record
TCustomer = Record
firstName : String;
lastName : String;
customer : TCustomer;
begin // Set up the John's customer details
with customer do
firstName := 'John';
lastName := 'Smith';
end; // Now show the details of our customer
ShowMessage('Customer name = '+customer.firstName+