[fpc-pascal] Type helper for array

Vojtěch Čihák vojtech.cihak at atlas.cz
Fri Jun 10 12:35:58 CEST 2016


@ But the question is whether he want to set the array to empty or if he wants to clear the array's contents without changing the size.
 
The second is right but it was not the point. "Clear" is just one example of several methods I want to encalupsate into TBuffer.
I decided use the type helper now. Another solution is class:
 
TBuffer = class
  Data: array of Single;
  procedure Create(ASize: Integer);
  procedure Clear;
end;
 
So I would call aBuffer.Data[3]:=5; instead of aBuffer[3]:=5;.
Thanks
______________________________________________________________
> Od: Sven Barth <pascaldragon at googlemail.com>
> Komu: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
> Datum: 10.06.2016 08:03
> Předmět: Re: [fpc-pascal] Type helper for array
>
Am 10.06.2016 07:36 schrieb "Jürgen Hestermann" <juergen.hestermann at gmx.de <juergen.hestermann at gmx.de>>:
 >
 > Am 2016-06-09 um 20:18 schrieb Sven Barth:
 >
 > > Am 09.06.2016 17:57 schrieb "Vojtech Cihák" <vojtech.cihak at atlas.cz <vojtech.cihak at atlas.cz>>:
 > > > aBuffer.Clear;
 > > > Is it possible to do this without helper?
 > >
 > > You can always set the array to Nil
 >
 > IMO SetLength(aBuffer,0) would the most natural way to clear the array.
*shrugs* That's also a way. Bit the question is whether he want to set the array to empty or if he wants to clear the array's contents without changing the size.
Regards,
 Sven

 
 ----------
 
 _______________________________________________
 fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
 http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal <http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160610/8c3da8cb/attachment.html>


More information about the fpc-pascal mailing list