Autor Beitrag
Coder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: So 20.02.05 19:48 
Hi
Wie kann ich die KB größe eines Elements in einem Record herausfinden?
Oder ist sowas garnicht möglich?
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: So 20.02.05 20:05 
Für Grundtypen SizeOf(Rec.item), für Strings Length, PChars mit StrLen, Arrays mit SizeOf(Arr[0]) * Length(Arr) und ansonsten musst Du gucken.

Poste am besten mal deinen Record.

_________________
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.
Coder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: So 20.02.05 20:19 
Danke :D
DelphiHilfe:
Bei Einzelbyte- und Multibyte-Strings gibt Length die Anzahl der Bytes in der Zeichenfolge zurück.

ausblenden Delphi-Quelltext
1:
2:
3:
  aData = record
    aText: String;
    ...

Ist das ein Einzelbyte-/Multibyte-String?

Nochmal für Dumme:
1 Buchstabe = 1 Byte und 1000 Buchstaben = 1 KB.
Oder hab ich da was falsch verstanden? :gruebel:
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: So 20.02.05 20:41 
Coder hat folgendes geschrieben:
1 Buchstabe = 1 Byte und 1000 Buchstaben = 1 KB.
Oder hab ich da was falsch verstanden? :gruebel:

Ja.
1024 Buchstaben = 1kB.

Aber auch das stimmt nicht genau.
Wenn man die "alten" Pascal-Strings nimmt, hat ein String noch ein Längen-Byte dazu.
Bei Null-Terminierten Strings müsste man theoretisch noch das Null-Byte dazu zählen.

Also hat man bei 1kB Buchstaben 1023 Zeichen plus dem Extra-Zeichen.
Coder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: So 20.02.05 21:23 
OK, Danke! :D
Stimmmt dieser Code?
Zitat:
Label1.Caption := Copy(FloatToStr(Length(Editor1.Text)/1024),1,4)+' KB';
Der Übersichtlichkeithalber nehme ich nur zwei Stellen nach den Komma.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: So 20.02.05 21:43 
Ich würde es so machen..
ausblenden Delphi-Quelltext
1:
Label1.Caption := Format('%.2f KB', [Length(Editor1.Text)/1024]);					

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
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: So 20.02.05 21:43 
Nein. Für 998.5 KB zeigt er 998, an ...

Genauso würde er bei 10MB langen Texten nur 1024 KB anzeigen ;-)

_________________
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.