Yes, the values in PDB files are big endian.  An offset of 0x0000012c
would be stored 00 00 01 2c, as opposed to 2c 01 00 00.  An easy way to
Endian swap in VB is to read 1 byte at a time and use math:

l = <read 1 byte>
l = l * 256
l = l + <read 1 byte>
l = l * 256
l = l + <read 1 byte>
l = l * 256
l = l + <read 1 byte>

In C (and maybe VB) you can make the * 256 much faster by bit shifting
(l <<= 8).

If you use the above with the first sequence (00 00 01 2c) you will see
that l ends up equal to 0x12c, which is what you want.

To write, you can do something similar.  Make sure your variable is an
integer type (no floating point):

b = l / 0x1000000
<write b as 1 byte>
l = l % 0x1000000  // I think % is Mod or Modulo in VB
// basically (pun intended) you are making l = the remainder
b = l / 0x10000
<write b as 1 byte>
l = l % 0x10000
b = l / 0x100
<write b as 1 byte>
b = l % 0x100
<write b as 1 byte>

Again, if you set l to 0x12c, you will get the big endian byte sequence.
And, again, you can make the divide much faster with >> 8.

Good Luck
-jjf

-----Original Message-----
From: Ken Miller [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 21, 2000 5:52 PM
To: Palm Developer Forum
Subject: Creating PDB files


I need to create a PDB database for a program I am working on and then
transfer it over to the Pilot.  When looking through the docs on the PDB
file format (The Pilot Record Database Format) it says that when
creating it
on the PC to be carefeul about the difference between the 68000 Motorola
storing as High Byte First and the PC storing Low Byte First - I take
this
to mean that numbers need to be saved in Big Endian format instead of
Little
Endian format.

Does anyone know of a good way to do this without first converting the
number to a binary string, reversing the string btyes and then
converting it
back to a number?  I am looking to do this in Visual Basic for easy
access
to an Access .mdb file, but any pointers will help :)

Thanks in advance.

Ken
[EMAIL PROTECTED]



__________________________________________________

Do You Yahoo!?

Talk to your friends online with Yahoo! Messenger.

http://im.yahoo.com


-- 
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palm.com/devzone/mailinglists.html

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to