Autor Beitrag
SatBL
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20



BeitragVerfasst: Fr 10.10.03 11:51 
Hallo zusammen,
ich bräuchte mal einen kleinen experten Tip. Ich versuche schon seit geraumer Zeit den Inhalt von 'fd' an den 'SendBuffer' zu übergeben.

Hier die definitionen.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
Type
  TFileDaten = Record
                     Word_1     : word;
                     Word_2     : word;
                     Small_1    : Smallint; 
                     Small_2    : Smallint; 
                end;            

var
  fd: TFileDaten; 
  SendBuffer: array[1..8of Char;



Wie kann ich dieses in möglichst einfacher Form tun, ich meine nicht z.B.:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
SendBuffer[1] := char(fd.Word_1 shr 8);
SendBuffer[2] := char(fd.Word_1);
SendBuffer[3] := char(fd.Word_2 shr 8);
SendBuffer[4] := char(fd.Word_2);
SendBuffer[5] := char(fd.Small_1 shr 8);
SendBuffer[6] := char(fd.Small_1);
SendBuffer[7] := char(fd.Small_2 shr 8);
SendBuffer[8] := char(fd.Small_2);


es müsste doch eine Möglichkeit geben das mit einer Schleife oder Zeiger zu bewältigen, oder liege ich da falsch.
Ich bekomme es nicht hin, bin zu blöde...
Kann mir jemand helfen, danke schon mal...

Mfg

Moderiert von user profile iconKlabautermann: Delphi-Tags hinzugefügt.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Fr 10.10.03 12:17 
Ganz easy! ;)
ausblenden Delphi-Quelltext
1:
CopyMemory(@SendBuffer, @fd, SizeOf(TFileDate);					

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
SatBL Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20



BeitragVerfasst: Fr 10.10.03 12:37 
Ja super, das ist ja einfach, danke werde ich gleich mal probieren.
SatBL Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20



BeitragVerfasst: Fr 10.10.03 13:04 
Hallo Motzi,
der Befehl funzt, er hat nur einen kleinen haken, er verdreht mir bei dem Word das LOW und HIGH Byte, d.h. es steht immer LHLHLHLH im SendBuffer, aber ich bräuchte HLHLHLHL.

Hast Du noch so eine simple Idee ??? :wink:
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Fr 10.10.03 13:23 
Das liegt nicht am Befehl, sondern an der internen Speicherung, die Words liegen nunmal so im Speicher! ;)

Aber du kannst die Word alle "swapen":
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure SwapWord(var w: Word);
begin
  w := ((w and $00FFshl 8or ((w shr 8and $00FF)
end;

Hoffe das stimmt so (is nicht getestet) ;)

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
SatBL Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20



BeitragVerfasst: Fr 10.10.03 13:34 
Jeep, haut hin, danke...