[fpc-pascal] Best way to insert bytes into a TBytes variable?

noreply at z505.com noreply at z505.com
Thu Jul 27 17:20:55 CEST 2017

On 2017-07-26 06:34, Sven Barth via fpc-pascal wrote:
> Am 26.07.2017 10:59 schrieb "Martok" <listbox at martoks-place.de>:
>> > Ideally the function should be portable between FPC and Delphi
> XE5...
>> You'd only need your own functions for Delphi, FPC's intrinsics such
> as Insert()
>> can already work with arrays:
>> var
>>   b, c: TBytes;
>> begin
>>   b:= TBytes.Create(1,2,3);
>>   c:= TBytes.Create(10,11);
>>   Insert(c,b,2);
>> -> b is now [1,2,10,11,3]
> But only in trunk. And Delphi XE8 and newer also support them.
> Regards,
> Sven

Oh, that would explain why it is not in the wiki/docs yet

Only issue I can see, is with all Create's, programmers expect a 
matching Free.
So that is a bit confusing, but so long as someone remembers arrays are 
garbage (reference rather) collected...

More information about the fpc-pascal mailing list