On Wed, Jun 10, 2009 at 8:25 PM, Fred Taylor<[email protected]> wrote:
> On Wed, Jun 10, 2009 at 12:24 PM, Paul Hill <[email protected]>wrote:
>
>> 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...
>>
>>
>>
> BITLSHIFT() and BITRSHIFT() don't cut it for you?

Hmmmm..... Never spotted those!  Thanks!

Here's a correction:
nHighByte = BITRSHIFT(BITAND(nLen, 0xFF00), 8)

-- 
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/[email protected]
** 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