Autor Beitrag
delphinia
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131

XP Pro Sp2
Delphi 5 Standard
BeitragVerfasst: Sa 03.12.05 22:07 
Führe ich diese Procedure aus, erhalte ich die Meldung das dies kein gültiger Integerwert sei!

kürze ich die nummer um nur 2 stellen ist alles ok!
hat jemand ne erklärung dafür?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.Button1Click(Sender: TObject);
var
add_nummer : integer;
begin
add_nummer := StrToInt('0041721234567');
end;
Grille
Hält's aus hier
Beiträge: 13

Win XP

BeitragVerfasst: Sa 03.12.05 22:20 
Nach meiner Meinung belegt der Integerwert 4 Byte.
Und ich habe gelernt Das der Integerwert von -2147483648 bis 2147483647 geht.
=> Deine Zahl ist zu groß
Wenn du die letzten beiden Ziffern löschst dann geht es, aber wenn du die beiden Nullen Löschst dann nicht(Wert zu groß). :)
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Sa 03.12.05 22:21 
Versuchs mal mit Int64

//EDIT: Ach, ich glaube, das gabs bei D5 noch nicht :(
delphinia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131

XP Pro Sp2
Delphi 5 Standard
BeitragVerfasst: Sa 03.12.05 22:25 
Doch int64 gibt es versuchte ich schon genauso wie longint und longword ;)
Alles die gleiche Meldung


Int64 laut D5 Hilfe Int64 -263..263 -1 64 Bit, mit Vorzeichen
root_at_localhost
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 191



BeitragVerfasst: Sa 03.12.05 22:27 
gibt's ne StrToInt64 ?
Alstar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 827



BeitragVerfasst: Sa 03.12.05 22:29 
user profile iconroot_at_localhost hat folgendes geschrieben:
gibt's ne StrToInt64 ?

Nein. Aber probiers mal damit: (Hat zumindest bei mir gefunzt)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.Button1Click(Sender: TObject);
var
  add_nummer : int64;
begin
  add_nummer := Round(StrToFloat('0041721234567'));
end;


Alstar
delphinia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131

XP Pro Sp2
Delphi 5 Standard
BeitragVerfasst: Sa 03.12.05 22:31 
user profile iconroot_at_localhost hat folgendes geschrieben:
gibt's ne StrToInt64 ?

wenn ich add_nummer : int64; nehme geht es mit StrToInt64

hat nur einen Nachteil der nimmt mir die Nullen weg - da ich aber nicht weis ob dort eine Null oder mehrer stehen wüsste ich nun gerade nicht wie ich das kompensieren kann ;)
delphinia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131

XP Pro Sp2
Delphi 5 Standard
BeitragVerfasst: Sa 03.12.05 22:32 
user profile iconAlstar hat folgendes geschrieben:
user profile iconroot_at_localhost hat folgendes geschrieben:
gibt's ne StrToInt64 ?

Nein. Aber probiers mal damit: (Hat zumindest bei mir gefunzt)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.Button1Click(Sender: TObject);
var
  add_nummer : int64;
begin
  add_nummer := Round(StrToFloat('0041721234567'));
end;


Alstar



ja das geht auch - nur auch hier das problem mit den Nullen siehe voriges posting
Alstar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 827



BeitragVerfasst: Sa 03.12.05 22:33 
user profile icondelphinia hat folgendes geschrieben:
user profile iconroot_at_localhost hat folgendes geschrieben:
gibt's ne StrToInt64 ?

wenn ich add_nummer : int64; nehme geht es mit StrToInt64

hat nur einen Nachteil der nimmt mir die Nullen weg - da ich aber nicht weis ob dort eine Null oder mehrer stehen wüsste ich nun gerade nicht wie ich das kompensieren kann ;)

Stimmt. Verdammt :oops:

Alstar
Allesquarks
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 510

Win XP Prof
Delphi 7 E
BeitragVerfasst: Sa 03.12.05 22:36 
Versteh das Problem nicht. Die Nullen müssen doch weg und wenns Ziffern sind werden die ja auch nicht entfernt.
delphinia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131

XP Pro Sp2
Delphi 5 Standard
BeitragVerfasst: Sa 03.12.05 22:37 
user profile iconAllesquarks hat folgendes geschrieben:
Versteh das Problem nicht. Die Nullen müssen doch weg und wenns Ziffern sind werden die ja auch nicht entfernt.


Nun die Nullen werden benötigt oder Telefonierst du bei Vorwahlen auch ohne NUll ;)
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Sa 03.12.05 22:40 
user profile icondelphinia hat folgendes geschrieben:
Nun die Nullen werden benötigt oder Telefonierst du bei Vorwahlen auch ohne NUll ;)

Wieso speicherst/behandelst Du eine Telefonnummer als Integer? :shock:
root_at_localhost
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 191



BeitragVerfasst: Sa 03.12.05 22:42 
sorry, aber telefonnummern sind per definition genau deshalb strings und zahlen im mathematischen sinne haben nunmal keine führenden nullen
Allesquarks
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 510

Win XP Prof
Delphi 7 E
BeitragVerfasst: Sa 03.12.05 22:43 
Von telephonieren war noch keine Rede.

Dann ist integer aber meiner Meinung nach das falsche Format. eine Telefonnummer ist eher eine Identifikationsnummer als eine Zahl.
Wenn ich mich recht erinnere steht vorne nur ne Null, wenn das ne Vorwahl oder sowas ist. Die haben aber feste größen könntest du also zurückbauen.
Oder mach doch nen Typ Telefonnummer mit Vorwahl und Nummer.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 03.12.05 22:43 
Also zwei Dinge:

1. Int64 gibt's seit D4. Davor hieß es Comp.

2. StrToInt64 gibt's AFAIR ab D5. Einzig StrToInt64Def gibt's erst ab D6.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
root_at_localhost
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 191



BeitragVerfasst: Sa 03.12.05 22:55 
Da muss ich dich korrigieren, in Delphi 4 sind sowohl StrToInt64 als auch StrToInt64Def vorhanden.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 03.12.05 23:06 
Kannst Du mir mal die Unit geben, in der die deklariert sind? Habs scheinbar bisher immer übersehen in D4.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
root_at_localhost
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 191



BeitragVerfasst: Sa 03.12.05 23:43 
Sind bei Delphi 4 deklariert in der SysUtils:
ausblenden Delphi-Quelltext
1:
2:
  function StrToInt64(const S: string): Int64;  
  function StrToInt64Def(const S: string; Default: Int64): Int64;


Mehr hab ich leider nicht, hab nur die Standard Edition, da gibts keine Sources.