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@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to