Best way of storing an "array of records" at design-time

Posted by smartins on Stack Overflow See other posts from Stack Overflow or by smartins
Published on 2010-03-20T00:18:40Z Indexed on 2010/03/20 0:21 UTC
Read the original article Hit count: 617

Filed under:

I have a set of data that I need to store at design-time to construct the contents of a group of components at run-time.

Something like this:

type
  TVulnerabilityData = record
    Vulnerability: TVulnerability;
    Name: string;
    Description: string;
    ErrorMessage: string;
  end;

What's the best way of storing this data at design-time for later retrieval at run-time? I'll have about 20 records for which I know all the contents of each "record" but I'm stuck on what's the best way of storing the data. The only semi-elegant idea I've come up with is "construct" each record on the unit's initialization like this:

var
  VulnerabilityData: array[Low(TVulnerability)..High(TVulnerability)] of TVulnerabilityData;

....

initialization
  VulnerabilityData[0].Vulnerability := vVulnerability1;
  VulnerabilityData[0].Name := 'Name of Vulnerability1';
  VulnerabilityData[0].Description := 'Description of Vulnerability1';
  VulnerabilityData[0].ErrorMessage := 'Error Message of Vulnerability1';

  VulnerabilityData[1]......
  .....
  VulnerabilityData[20]......

Is there a better and/or more elegant solution than this?

Thanks for reading.

© Stack Overflow or respective owner

Related posts about delphi