[Overview][Types][Classes][Index] |
Swaps the line values at the specified positions.
Source position: textstrings.pas line 85
public procedure TTextStrings.Exchange( |
Index1: Integer; |
Index2: Integer |
); override; |
Index1 |
|
First position for the value exchange. |
Index2 |
|
Second position for the value exchange. |
Exchange is an overridden method used to swap the line values at the positions specified in Index1 and Index2. No actions are performed in the method when Index1 and Index2 contain the same value.
Values in Index1 and Index2 must be in the range 0..Count-1 or an EStringListError exception is raised.
BuildArrays is called to populate the internal array of TTextLineRange instances when the internal validity flag is not set. MakeTextBufferUnique is called to ensure that the reference count for the Text member is 1.
When Index2 is the last line of text, a LineEnding sequence is added to Text when not already present.
GetLineLen is called to get the length for both lines including end-of-line characters. Temporary buffers are allocated for both TTextLineRange instances, and a memory buffer is allocated using the size for the larger of the two lines. The largest line is saved to the memory buffer, and used to shift the values in Text as needed. Range information for lines between Index1 and Index2 are adjusted to reflect their new start and end positions.
Exchange also swaps the values in the Objects property at the specified index positions.
Exchange re-implements the method defined in the ancestor, and does not call the inherited method.
Version 4.0 | Generated 2025-05-03 | Home |