Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 1 of 1 total
Thread On the Copy function
Thu, Nov 21 2019 1:26 AMPermanent Link

Michael Dreher

I have taken over a function

function RightStr(const s : string; len : integer) : string;
begin
 Result := Copy(s, Length(s) - len + 1, len);
end;

from my Delphi code into an EWB application. It works as
expected, except for this one:

procedure foo;
var s : string;
begin
 s := RightStr('123', 4); // (i)
 s := RightStr('123', 5); // (ii)     
end;

The results:

#      Delphi      EWB 2.06B20
------------------------------
(i)    '123'       '3'
(ii)   '123'       '23'

A bug? Looks like for <from-index> values <= 0 the
Copy function looks from the last character to the left.

M. Dreher
Image