Difference between revisions of "Delete"

From SCAR Divi Manual
Jump to: navigation, search
 
Line 10: Line 10:
  
 
==Description==
 
==Description==
Removes a range of elements/[[characters|char]] from an [[|arrays|array]]/[[string]]. In case of an array, the array is passed in '''arr''', the start index to remove in '''index''' and the number of items to remove in '''count'''. In case of a string, the string is passed in '''arr''', the position of the first character to remove in '''index''' and the number of characters to remove in '''count'''.
+
Removes a range of elements/[[char|characters]] from an [[arrays|array]]/[[string]]. In case of an array, the array is passed in '''arr''', the start index to remove in '''index''' and the number of items to remove in '''count'''. In case of a string, the string is passed in '''arr''', the position of the first character to remove in '''index''' and the number of characters to remove in '''count'''.
  
 
==Example 1 (Arrays)==
 
==Example 1 (Arrays)==

Latest revision as of 12:14, 16 November 2011

Definition

procedure Delete(var arr; index, count: Integer);

Availability

SCAR Divi 3.00 > Current

  • Array functionality was added in 3.25

Description

Removes a range of elements/characters from an array/string. In case of an array, the array is passed in arr, the start index to remove in index and the number of items to remove in count. In case of a string, the string is passed in arr, the position of the first character to remove in index and the number of characters to remove in count.

Example 1 (Arrays)

var
  TIA: TIntArray;

begin
  TIA := [2, 4, 6, 8, 10];
  Delete(TIA, 2, 2);
  WriteLn(TIAToStr(TIA));
end.

Output:

2,4,10

Example 2 (Strings)

var
  s: AnsiString;

begin
  s := 'Hello World!'
  Delete(s, 6, 6);
  WriteLn(s);
end.

Output:

Hello!

See Also