You've got:
SCAR Code:
FromX[i]:= C;
ToX[i]:= E;
You want:
SCAR Code:
C := FromX[I];
E := ToX[I];
That solves your out of string range error.
But you also need to put the Delete(...); line inside the if (I <> 0) then begin, end loop.
So....:
SCAR Code:
function DeleteMulti(Text : string; FromX, ToX : TIntegerArray) : string;
var
I, D, C, E : Integer;
S : string;
begin
S:= Text
for I:= 0 to High(FromX) do
begin
if I <> 0 then
begin
C := FromX[I];
E := ToX[I];
if (Pos(Text[C], S) > Pos(Text[C - 1], S)) then //Line 16
D:= D + (Pos(Text[C - 1], S) - Pos(Text[E - 1], S));
Delete(Text, FromX[I - D], ToX[I - D]);
end;
end;
Result:= Text;
end;
SCAR Code:
writeln(deletemulti('hi how are you today"', [3, 7], [5, 9]));
hi howtoday"
EDIT: Hmmm I don't think that works.. but I gtg
.