[Overview][Constants][Types][Classes][Procedures and functions][Variables] Reference for unit 'Classes' (#rtl)

TStrings.Move

Move a string from one place in the list to another.

Declaration

Source position: classesh.inc line 499

public procedure TStrings.Move(

  CurIndex: Integer;

  NewIndex: Integer

); virtual;

Description

Movemoves the string at position CurIndexso it has position NewIndexafter the move operation. The object associated to the string is also moved. CurIndexand NewIndexshould be in the range of 0to Count-1.

Remark:

NewIndexis notthe position in the stringlist before the move operation starts. The move operation

  1. removes the string from position CurIndex
  2. inserts the string at position NewIndex

This may not lead to the desired result if NewIndexis bigger than CurIndex. Consider the following example:

With MyStrings do
    begin
    Clear;
    Add('String 0');
    Add('String 1');
    Add('String 2');
    Add('String 3');
    Add('String 4');
    Move(1,3);
    end;

After the Moveoperation has completed, 'String 1' will be between 'String 3' and 'String 4'.

Errors

If either CurIndexor NewIndexis outside the allowed range, an EStringListErroris raised.

See also

TStrings.Exchange

  

Exchanges two strings in the list.