Autor Beitrag
blume283
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 23


Delphi 7
BeitragVerfasst: Mo 17.12.07 15:44 
hallo,

ich habe zb einen eigenen typ definiert:

type

TObst = (obApfel, obBirne, obPflaume);

nun brauche ich dazu so etwas wie

Length(TObst), das mir dann =3 zurückliefert.

Es geht natürlich mit (High(TObst) - Low(TObst) + 1), aber geht es noch anders?

viele grüße

blume
Martin1966
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1068

Win 2000, Win XP
Delphi 7, Delphi 2005
BeitragVerfasst: Mo 17.12.07 16:09 
user profile iconblume283 hat folgendes geschrieben:
aber geht es noch anders?

Nicht das ich wüsste, warum?

Lg, Martin

_________________
Ein Nutzer der Ecke ;-)
hazard999
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 162

Win XP SP2
VS 2010 Ultimate, CC.Net, Unity, Pex, Moles, DevExpress eXpress App
BeitragVerfasst: Mo 17.12.07 16:14 
Hallo,

warum high - low + 1?

High(TObst) + 1 sollte reichen.

und warum anderst?

r u

René

_________________
MOV EAX, Result;MOV BYTE PTR [EAX], $B9;MOV ECX, M.Data;MOV DWORD PTR [EAX+$1], ECX;MOV BYTE PTR [EAX+$5], $5A;MOV BYTE PTR [EAX+$6], $51;MOV BYTE PTR [EAX+$7], $52;MOV BYTE PTR [EAX+$8], $B9;MOV ECX, M.Code;MOV DWORD PTR [EAX+$9], ECX
blume283 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 23


Delphi 7
BeitragVerfasst: Mo 17.12.07 16:17 
wär doch praktisch oder gibt es eine möglichkeit

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
type
 TObst = (obApfel, obBirne, obPflaume);
 TGemuese = (geTomate, gePaprika);

var
 Obst : TObst;
 Gemuese : TGemuese;

function Laenge(myowntype) : Integer;

// so dass ich folgendes aufrufen kann:

Laenge(TObst)
Laenge(TGemuese)

bzw.

Laenge(Obst)
Laenge(Gemuese)


geht das irgendwie einzubauen, dass man halt einen beliebigen eigenen Datentyp per Funktion übergeben kann?

viele grüße

nils
hazard999
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 162

Win XP SP2
VS 2010 Ultimate, CC.Net, Unity, Pex, Moles, DevExpress eXpress App
BeitragVerfasst: Mo 17.12.07 16:32 
schau dir mal GetTypeData an.

unit TypInfo

da ist alles drin was du brauchst.

r u

René

_________________
MOV EAX, Result;MOV BYTE PTR [EAX], $B9;MOV ECX, M.Data;MOV DWORD PTR [EAX+$1], ECX;MOV BYTE PTR [EAX+$5], $5A;MOV BYTE PTR [EAX+$6], $51;MOV BYTE PTR [EAX+$7], $52;MOV BYTE PTR [EAX+$8], $B9;MOV ECX, M.Code;MOV DWORD PTR [EAX+$9], ECX
blume283 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 23


Delphi 7
BeitragVerfasst: Mo 17.12.07 16:40 
thx werd ich gleich mal schauen