[fpc-pascal] Partially initializing array of records

Clay Stuart clay.stuart at gmail.com
Wed Jul 20 07:04:51 CEST 2011


Ok.  Thanks everyone.

Clay

On Tue, Jul 19, 2011 at 2:30 PM, Martin <fpc at mfriebe.de> wrote:

> On 19/07/2011 19:05, Clay Stuart wrote:
>
>> How do people initialize large amounts of information in practice?  Do
>> they just read in files and convert them over dynamically?
>>
>
> There is an example for pre-initialized variable length arrays in
>  ide\editoroptions.pp line 550 and before.
>
> EditorOptionsFoldDefaults: array[TLazSyntaxHighlighter] of
>    TEditorOptionsFoldRecord =
>    ( (Count:  0; Info: nil), // none
>      (Count:  0; Info: nil), // text
>      (Count: 23; Info: {$IFDEF FPC}@{$ENDIF}**EditorOptionsFoldInfoPas[0]),
> // Freepas
>      (Count: 23; Info: {$IFDEF FPC}@{$ENDIF}**EditorOptionsFoldInfoPas[0]),
> // pas
>      (Count:  3; Info: {$IFDEF FPC}@{$ENDIF}**EditorOptionsFoldInfoLFM[0]),
> // lfm
>
>
> it uses pointers though
>
>  TEditorOptionsFoldInfoList = Array [0..999] of TEditorOptionsFoldInfo;
>  PEditorOptionsFoldInfoList = ^TEditorOptionsFoldInfoList;
>
>  TEditorOptionsFoldRecord = record
>    Count: Integer;
>    Info: PEditorOptionsFoldInfoList;
>  end;
>
>
> The pointer does not care, that it points to an array defined with a
> different length....
> of course, you must ensure not to access elements outside the boundaries,
> as all the nice things like range-checks will no longer work....
>
> Afaik the array declaration isn't even needed, just using pointers would
> already do the trick....
>
>
>
>
> ______________________________**_________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.**org<fpc-pascal at lists.freepascal.org>
> http://lists.freepascal.org/**mailman/listinfo/fpc-pascal<http://lists.freepascal.org/mailman/listinfo/fpc-pascal>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20110720/7964f766/attachment.html>


More information about the fpc-pascal mailing list