[fpc-pascal] Delete and Add for TBytes?
bo.berglund at gmail.com
Wed Jul 12 21:17:52 CEST 2017
On Wed, 12 Jul 2017 16:26:31 +0200 (CEST), Michael Van Canneyt
<michael at freepascal.org> wrote:
>> Is it possible to overload Delete() so it can be called with TBytes as
OK, then I am doing it erroneously....
(Testing in Delphi XE5 at the moment, but trying to write it to be
portable since the unit that needs this is used both in Delphi and
This is how I did it:
In a utility unit "CommonFuncs" normally put into the uses clause of
most source files I added this:
// Byte buffer handling 2017-07-12 BB
procedure Delete(var Buf: TBytes; Index, Count: integer); overload;
procedure Delete(var Buf: TBytes, Index, Count: integer); overload;
Move(Buf[Index+Count], Buf[Index], Length(Buf)-Index - Count);
SetLength(Buf, Length(Buf) - Count);
Then I did a syntax check and it errored out on a line way up in
CommonFuncs (actually the first use of Delete in the implementation
[dcc32 Error] CommonFuncs.pas(357): E2250 There is no overloaded
version of 'Delete' that can be called with these arguments
The line looks like this:
Delete(sVal, i, 1);
where sVal is a string, i.e. it should not be affected by the new
Delete since it is not a TBytes variable.
Apparently the System.Delete procedure is missing the "overload"
So, what steps do I take in order to "overload" Delete in such a way
that strings will still use the System.Delete?
Developer in Sweden
More information about the fpc-pascal