VFP 9 has   
   BitLShift() and BitRShift()   
   CToBin/BinToC have the cFlag "R" - Reverses the binary expression.   


But your solution works, I'm sure!


Tracy

-----Original Message-----
From: Paul Hill
Sent: Wednesday, June 10, 2009 3:24 PM

On Wed, Jun 10, 2009 at 3:38 PM, Kent Belan<[email protected]> wrote:
> Hello,
> I need help with a Formula.
>
> I have a message of variable length and need to calculate the message 
> header.
>
> Here is the formula:
> The message header length is two bytes, binary, big-endian (high-order 
> byte
> first)

Try this:

cMessage = do_my_stuff()
nLen = LEN(cMessage)

nHighByte = INT(BITAND(nLen, 0xFF00) / 256) nLowByte = BITAND(nLen, 0x00FF)

cHeader = CHR(nHighByte) + CHR(nLowByte)

** I guess you need to end up with this:
cNewMessage = cHeader + cMessage

I don't think CTOBIN() as Tracy suggested supports big-endian.

I wish fox had a BitShift() function...

--
Paul



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/000d01c9ea09$8c789dd0$a569d9...@com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to