Mombu the Programming Forum

Go Back   Mombu the Programming Forum > Programming > stupidly desperate..halfword??
User Name
Password
REGISTER NOW! Mark Forums Read




Reply
1 11th September 21:53
phr0zen
External User
 
Posts: 1
Default stupidly desperate..halfword??



does anybody know what is the delphi equivalent of fortran's halfword?

i have 2 byte variables..how would i convert that to a halfword??

Message header block:

HWORD# BYTE# MEANING

1 1-2 Product code
2 3-4 Date of message (Days since 1 Jan 1970)
3-4 5-8 Time of message (seconds since midnight GMT)
5-6 9-12 Number of bytes in message
7 13-14 Numeric radar site ID
8 15-16 Numeric product destination ID
9 17-18 Number of data blocks in message

having a rough time figurin this out! .
  Reply With Quote


 


2 11th September 21:53
rob kennedy
External User
 
Posts: 1
Default stupidly desperate..halfword??



If I knew that that did, I could tell you the equivalent. You might be
looking for the MakeWord function, in the Windows unit.


If you have two bytes, then you already have *two* half-words. In
Delphi, a Word is 16 bytes wide.


type
TMessageHeaderBlock = packed record
ProductCode,
Date: Word;
Time: LongWord;
ByteCount: LongWord;
RadarSiteID,
ProductDestinationCode,
DataBlockCount: Word;
end;

Read the header block into a variable of type TMessageHeaderBlock, and
you should have all your data. The only problem would be if the header
block were in big-endian byte order; the record above is in
little-endian order. It's a simple task to swap the byte positions, though.

--
Rob
  Reply With Quote
3 11th September 21:53
rob kennedy
External User
 
Posts: 1
Default stupidly desperate..halfword??


Er, bits. A Word is 16 *bits* wide.

--
Rob
  Reply With Quote
4 11th September 21:53
phr0zen
External User
 
Posts: 1
Default stupidly desperate..halfword??


it is in big endian order...how do i do that simple task?
  Reply With Quote
5 11th September 21:53
phr0zen
External User
 
Posts: 1
Default stupidly desperate..halfword??


I think i got it figured ..i used Swap() and the values match up now!
thank you all very much!
  Reply With Quote
6 11th September 21:53
rob kennedy
External User
 
Posts: 1
Default stupidly desperate..halfword??


function Swap32(X: LongWord): LongWord;
asm
bswap eax
end;

function Swap16(X: Word): Word;
asm
bswap eax
shr eax, 16
end;

Apply the first function to the 32-bit fields in your record, and apply
the second function to the 16-bit fields.

--
Rob
  Reply With Quote
7 22nd September 23:05
cajunreaper
External User
 
Posts: 1
Default stupidly desperate..halfword??


I noticed you are decoding a NWS code file. Have you gotten the record to
work?

does the file you are decoding have a WMO header (do you skip it)

Thanks,
CajunReaper
  Reply With Quote
Reply


Thread Tools
Display Modes




666