Autor Beitrag
g1o2k4
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 493



BeitragVerfasst: Mo 01.01.07 17:29 
ich möchte eine zahl aus einem editfenster in eine cardinal variable umwandeln...
was ist cardinal überhaupt ? steh grad aufm schlauch.


Zuletzt bearbeitet von g1o2k4 am Mo 01.01.07 17:43, insgesamt 1-mal bearbeitet
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 01.01.07 17:34 
Kardinal ist ein Rang in der katholischen Kirche, ähnlich einem Bischof, jedoch mit Wahlrecht bei der Papstwahl. :mrgreen:

Cardinal ist ein Ganzzahl-Datentyp. Umwandeln eines String in ein Cardinal dürfte per IntToStr gehen. Ob man das Vorzeichen gesondert behandeln mus (Cardinal ist ja nur positiv), oder ob IntToStr auch eine Cardinal-Überladung hat, weiß ich grad nicht auswendig.


Edit: Argh...Ich meinte natürlich StrToInt :autsch:

_________________
We are, we were and will not be.


Zuletzt bearbeitet von Gausi am Mo 01.01.07 17:35, insgesamt 1-mal bearbeitet
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: Mo 01.01.07 17:34 
'cardinal' verwendet man für vorzeichenlose 32-Bit-Ganzzahlen. ;) Probiere doch einfach mal strtoint(). ;)
user profile icong1o2k4 hat folgendes geschrieben:
was ist kardinal überhaupt ?

Kardinal ist ein vom Papst verliehener religiöser Titel, der den Träger zur Papstwahl berechtigt und ihn zur besonderen Mitverantwortung an der Gesamtleitung der Kirche („Senat des Papstes“) verpflichtet. :mrgreen:
Edit: Zu langsam... :motz:

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Mo 01.01.07 18:11 
user profile iconMarco D. hat folgendes geschrieben:
'cardinal' verwendet man für vorzeichenlose 32-Bit-Ganzzahlen. ;) Probiere doch einfach mal strtoint(). ;)

Das wird leider nicht (immer) gehen.
Probier mal diesen Code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
var c:Cardinal;
begin
  c:= StrToInt('4294000000');
end;

Na, was passiert? Richtig, Überlauf. Die Zahl ist zwar ein gültiger Cardinal oder DWORD-Wert, aber für Integer schon viel zu groß.
Und zum Vergleich:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
var c:Cardinal;
begin
  c:= StrToInt64('4294000000');
end;

Hier muss man also erst in den größeren Datentyp Int64 konvertieren, um den dann von Delphi zu DWORD machen zu lassen.
Das gleiche gilt auch für die andere Richtung:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
var s:Cardinal;
begin
  s:= Int64ToStr(4294000000);
end;


HTH, Martok

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."