[fpc-pascal] Delete and Add for TBytes?

Sven Barth pascaldragon at googlemail.com
Thu Jul 13 00:15:40 CEST 2017


Am 12.07.2017 16:08 schrieb "Bo Berglund" <bo.berglund at gmail.com>:
> To remove Count processed bytes from the beginning:
>
> Buffer: AnsiString;
>
> Delete(Buffer, 1, Count)
> or worse:
> Buffer := Copy(Buffer, Count+1, Length(Buffer));

FPC trunk supports Delete() and Insert() on dynamic arrays (TBytes is
merely a dynamic array) and Copy() is supported for longer already. You
merely need to adjust the indices to 0-based instead of 1-based.
Delete() and Insert() are also supported by Delphi XE8 and newer I think.

> For adding new data (c: AnsiChar) to the end:
>
> Buffer := Buffer + c;

The + operator is not yet implemented by default on FPC (neither is
Concat()), but you can easily declare that yourself.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20170713/f8425ae6/attachment.html>


More information about the fpc-pascal mailing list