AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Object-Pascal / Delphi-Language Delphi Konstantes Array aus Records die variables Array enthalten ?
Thema durchsuchen
Ansicht
Themen-Optionen

Konstantes Array aus Records die variables Array enthalten ?

Ein Thema von kaiser1401 · begonnen am 28. Mai 2008 · letzter Beitrag vom 28. Mai 2008
 
Benutzerbild von nicodex
nicodex

Registriert seit: 2. Jan 2008
Ort: Darmstadt
286 Beiträge
 
Delphi 2007 Professional
 
#7

Re: Konstantes Array aus Records die variables Array enthalt

  Alt 28. Mai 2008, 14:46
Zitat von uligerhardt:
Nicos Variablennamen sind natürlich besser.
Dafür war ich zu faul die Komponentenlisten 'lesbar' zu initialisieren

Wenn man beides kombiniert, dann könnte es so aussehen:
Delphi-Quellcode:
unit Foobar;

interface

uses
  Controls;

type
  TCmeMaskType = (mtSearch, mtImport);
  TCmeMaskTypes = set of TCmeMaskType;
  TCmeComponent = record
    CtrlClass: TControlClass;
    MaskTypes: TCmeMaskTypes;
  end;
  TCmeComponentTab = record
    TabName: string;
    Components: array of TCmeComponent;
  end;
  TCmeComponentCollection = array of TCmeComponentTab;

implementation

uses
  StdCtrls;

var
  GCompRec: TCmeComponentCollection;

procedure InitCompRec();
type
  TCompRec = (
    crStandard,
    crAdditional
  );
  TCompRecStandard = (
    crStandardLabel,
    crStandardEdit
  );
  TCompRecAdditional = (
    crAdditionalMemo
  );
  PCmeComponentArray = ^TCmeComponentArray;
  TCmeComponentArray =
    array [0..High(Integer) div SizeOf(TCmeComponent) - 1] of TCmeComponent;
resourcestring
  StrCompRecTabNameStandard = 'Standard';
  StrCompRecTabNameAdditional = 'Additional';
const
  CompRecTabNames: array [TCompRec] of string = (
    StrCompRecTabNameStandard,
    StrCompRecTabNameAdditional
  );
  CompRecStandard: array [TCompRecStandard] of TCmeComponent = (
    (
      CtrlClass: TLabel;
      MaskTypes: []
    ),
    (
      CtrlClass: TEdit;
      MaskTypes: [mtSearch]
    )
  );
  CompRecAdditional: array [TCompRecAdditional] of TCmeComponent = (
    (
      CtrlClass: TMemo;
      MaskTypes: []
    )
  );
  CompRecComponents: array [TCompRec] of record
    High: Integer;
    Comp: ^TCmeComponent;
  end = (
    (
      High: Integer(High(CompRecStandard));
      Comp: @CompRecStandard;
    ),
    (
      High: Integer(High(CompRecAdditional));
      Comp: @CompRecAdditional;
    )
  );
var
  Entry: TCompRec;
  Index: Integer;
begin
  SetLength(GCompRec, Integer(High(TCompRec)) + 1);
  for Entry := Low(TCompRec) to High(TCompRec) do
    with GCompRec[Integer(Entry)] do
    begin
      TabName := CompRecTabNames[Entry];
      with CompRecComponents[Entry] do
      begin
        SetLength(Components, High + 1);
        for Index := 0 to High do
          Components[Index] := PCmeComponentArray(Comp)[Index];
      end;
    end;
end;

initialization

  InitCompRec();

end.
Sieht zwar immer noch 'hässlich' aus, aber für übersichtlicheren Code müsste man das Struktur/Schnittstellen-Design ändern...
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:44 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz