Longword und Real in Delphi einlesen?

  • 1
  • 2
  • 3
  • Page 1 of 3
Lschreyer
Schreiberling
Avatar
Gender: n/a
Posts: 526
Registered: 02 / 2007
Subject:

Longword und Real in Delphi einlesen?

 · 
Posted: 25.09.2010 - 15:39  ·  #1
Ich habe auf eine SD-Card eine File of Byte erzeugt und da ein paar Records hineingeshrieben.

Das Record sieht so aus:

Recdatarec = record
Flightno: Byte; //1..6
GOffSet: smallint;
PPAD, PMIN: longword;
BtempPad: Int64;
preflightpages, CurPage, Startpage, Endpage, recswritten, dpp: Word;
end;

Das klappt auch alles wunderbar, nur wenn ich dieselbe Datei auf meinem PC über ein Delphi-Programm einlesen möchte kommt da bei den Longwords und INt64nur Datensalat.

Mir ist soweit bekannt, dass man für Integer in Avrco ein SmallInt bei Delphi nehmen muss.
Welche Datentypen in Delphi entsprechen den Longword und INt64?

Louis
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: Longword und Real in Delphi einlesen?

 · 
Posted: 25.09.2010 - 16:14  ·  #2
Hallo Louis,

zuerstmal muss bei Delphi hier ein packed record angegeben werden. Ansonsten belegen z.B. Bytes den Platz von vier Bytes.
AVRco LongWord ist bei Delphi Word.
AVRco Int64 ist auch bei Delphi Int64.

rolf
Lschreyer
Schreiberling
Avatar
Gender: n/a
Posts: 526
Registered: 02 / 2007
Subject:

Re: Longword und Real in Delphi einlesen?

 · 
Posted: 25.09.2010 - 16:28  ·  #3
Vielen Dank, Packed Record hat geholfen.

Longword ist aber in Delphi offenbar auch Longword, kann das sein?
Float = Single
Integer = Smallint

Wie immer, super Service, sogar am Samstag :-) Bin immer wieder begeistert!

Louis
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: Longword und Real in Delphi einlesen?

 · 
Posted: 25.09.2010 - 17:18  ·  #4
Hallo Louis,

in Delphi ist
Word = LongWord
Integer = LongInt
Dies gilt seit Delphi32 (ist schon einige Jahre her).

rolf
mc-electronic
Benutzer
Avatar
Gender: n/a
Location: Sauerland NRW
Posts: 372
Registered: 03 / 2008
Subject:

Re: Longword und Real in Delphi einlesen?

 · 
Posted: 27.09.2010 - 16:36  ·  #5
Hallo Rolf,

lese im aktuellen Projekt allerlei binäre AVRco Files von MMC ein, mit packed Records, klar, damit die Datentypen nicht im 4-Byte Raster, sondern in ihrem 'echten' Format abgelegt werden. Allerdings setze ich AVRco Word (2Byte) = Delphi Word, sowie AVRco LongWord (4 Byte) = Delphi LongWord und das funktioniert auch völlig korrekt. Daher bin ich mit Louis einer Meinung.

Arbeite mit Delphi 7.

Gruß, Michael
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: Longword und Real in Delphi einlesen?

 · 
Posted: 27.09.2010 - 16:39  ·  #6
Hallo Michael,

da war ich wohl auf dem falschen Dampfer, da bei Delphi integer gleich LongInt ist war für mich word gleich longword...

rolf
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1373
Registered: 03 / 2005
Subject:

Re: Longword und Real in Delphi einlesen?

 · 
Posted: 27.09.2010 - 17:00  ·  #7
Hi All.

Delphi is a bit like C in its choice of definitions. Types like byte, word and so on have fixed meaning globally accepted, but integer and (regrettably) char are a moveable feast.

When ANSI standards committee defined integers for C they deliberately did not specify its length. The idea was to make C more portable (sic) so the compiler was supposed to chose the best size for its target. Thus on 16 bit processors, int was 15 bits plus a sign bit. On 32 bit processors int was 31 bits plus a sign bit, and so on, and Delphi has taken the same approach.

But Word is still 16 bits, over all versions of Delphi and all targets.

Did you know, though, that char is now, by default, 2 bytes wide on Delphi? (I think since Dephi 2009, but I could be wrong on that score). So beware when passing strings between Delphi and AVRCo!

Regards

Merlin.
mc-electronic
Benutzer
Avatar
Gender: n/a
Location: Sauerland NRW
Posts: 372
Registered: 03 / 2008
Subject:

Re: Longword und Real in Delphi einlesen?

 · 
Posted: 27.09.2010 - 17:25  ·  #8
Hi Merlin,

thanks for the warning, a char now 2 bytes? - uh-huh. That is the problem with updates, new software, new problems.

Cheers, Michael
  • 1
  • 2
  • 3
  • Page 1 of 3
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   140   154 · Page-Gen-Time: 0.038661s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI