Autor Beitrag
Alstar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 827



BeitragVerfasst: Di 10.05.05 16:41 
Hallo!

Ich stehe vor einem Problem: Ich möchte einen eigenen Datentyp (eine eigenen Variablentyp) definieren, der das Aussehen eines arrays 1..5 of Byte hat (also aufruf mit Variable[1] := 255). Das alleine ist ja nicht schwehr, aber ich möchte dem ganzen jetzt noch Prozeduren und Funktionen mitgeben (aufruf mit Variable.Procedur1).

Geht sowas?

Alstar
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Di 10.05.05 16:44 
eigenen Type definieren
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
type TmeinArrayTyp=array [1..5] of byte;

...
Var meinArray:TmeinarrayTyp;
...

Procedure irgendwas(meinArray:TmeinarrayTyp); 
...
usw

oder in der OH einfach mal unter "Array-Paramter" guggn

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
Alstar Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 827



BeitragVerfasst: Di 10.05.05 16:46 
Nein. Sowas wollte ich ja vermeiden, dann hieße es ja

ausblenden Delphi-Quelltext
1:
  Irgendwas(MeinTyp);					


aber ich will z.b:

ausblenden Delphi-Quelltext
1:
2:
  MeinTyp[3] := 4;
  MeinTyp.Irgendwas;


Alstar
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Di 10.05.05 16:48 
achso, falsch verstanden.
Dann mach dich mit Objektorientierter Programmierung vertraut, dazu gibts es unmengen Tutorials, z.B. www.dsdt.info/grundlagen/sprache/

mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Di 10.05.05 16:50 
vielleicht über einen Record? Außer man kann dort keine Proceduren definieren....

_________________
Programmers never die, they just GOSUB without RETURN
Alstar Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 827



BeitragVerfasst: Di 10.05.05 16:53 
Achso.... Klar mit Klassen geht das ja auch ...
Sry. Hab mal wieder viel zu umständlich gedacht!!

thx

Alstar
Grendel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 443

Gentoo Linux, MacOS X, Win 2000
D5 Ent, D7 Ent, Lazarus, Anjuta, MonoDevelop
BeitragVerfasst: Di 10.05.05 16:57 
Bau Dir eine Klasse um die Liste/ das Array.

Um den Zugriff auf Listenelemente ueber den Index zu bekommen muss das entsprechende Property ungefähr so aussehen.
ausblenden Delphi-Quelltext
1:
    property Values[Index: Integer]: Byte read GetValues; default;					

und "GetValues" würde dann so aussehen
ausblenden Delphi-Quelltext
1:
2:
3:
4:
function [...].GetValues(Index: Integer): Byte;
begin
  Result := Array[Index];
end;


Bis neulich ...