Autor Beitrag
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Do 13.07.06 17:32 
Einer Integer-Property darf kein Wert gleich oder kleiner als 0 zugewiesen werden. Ich möchte mit einer Set-Prozedur dies überprüfen. Wie sieht die Syntax aus?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
private
FIntegerFeld : integer;
procedure SetIntegerFeld //???
public
property IntegerFeld : integer read FIntegerFeld write SetIntegerFeld; //ab write weiß ich nicht weiter?!?

Wie muss das aussehen?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Do 13.07.06 17:34 
Titel: Re: OOP: Verhindern das Integer-Property <= 0 zugewiesen wir
user profile iconMarco D. hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
private
FIntegerFeld: integer;
procedure SetIntegerFeld(const Value: Integer) //???
public
property IntegerFeld : integer read FIntegerFeld write SetIntegerFeld; //ab write weiß ich nicht weiter?!?

...

procedure SetInt....
begin
  if Value < 0 then
    FIntegerFeld := 0
  else FIntegerFekd := Value;
end;


_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Do 13.07.06 17:39 
Muss vor Value das const unbedingt?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Do 13.07.06 17:45 
wenn ich Strg+Shift+C mach, wird es so angelegt, muss aber nicht sein

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
digi_c
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1905

W98, XP
D7 PE, Lazarus, WinAVR
BeitragVerfasst: Fr 14.07.06 07:34 
Wieso nimmst du eigentlich nicht gleich Cardinaloder Byte, Word, Longwordals Datentyp?
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Fr 14.07.06 11:28 
user profile icondigi_c hat folgendes geschrieben:
Wieso nimmst du eigentlich nicht gleich Cardinaloder Byte, Word, Longwordals Datentyp?

Wieso sollte ich? ;)

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot