Board index » delphi » "word" data type

"word" data type

I am working on a program which needs to read a Turbo Pascal data
base.  I am using Visual Basic to write the program.  VB apparently
does not have an equivalent to the "word" data type.

If anyone can help me understand the "word" data type I will
appreciate it.  How is it structured?  Hopefully, I can write some
sort of conversion routine.

If anyone knows how to convert a "word" field  to C I could take it
from there.

Again, any information will be appreciated.  thanks.

 

Re:"word" data type


The WORD data type is a simple 16 bit unsigned integer.  When written to a
file, the most significant byte will be written second as a memory image
is copied to the file.

Re:"word" data type


Quote
In article <31e4749f.1234...@nntp.ix.netcom.com> cmill...@ix.netcom.com (chuck miller) writes:
>I am working on a program which needs to read a Turbo Pascal data
>base.  I am using Visual Basic to write the program.  VB apparently
>does not have an equivalent to the "word" data type.
>If anyone can help me understand the "word" data type I will
>appreciate it.  How is it structured?  Hopefully, I can write some
>sort of conversion routine.
>If anyone knows how to convert a "word" field  to C I could take it
>from there.

A Pascal word is just a 16-bit unsigned integer value.  As long as you're
staying within 80x86, it shouldn't be much of a problem -- 80x86 stores
numbers little-endian (i.e., the lower byte of a word comes first, then the
higher byte).  One thing to remember.  Generally in C, int may be 16 or 32
bits, depending on the compilation.

Where you have in Pascal:

var
  myvar : word;

that would be in a 16-bit target compilation:

  unsigned int myvar;

or in a 32-bit target compilation:

  unsigned short int myvar;

You could also use preprocessor directives to your advantage:

#define WORD unsigned int

/* ... */

void myproc (void)
{
  WORD myvar;

  /* do whatever */

Quote
}

At least that's how to handle it in C.  You're on your own in VB.

Quote
>Again, any information will be appreciated.  thanks.

Is that enough information?

--
Scott Earnest          | We now return you to our regularly scheduled |
siny...@{*word*104}space.org | chaos and mayhem. . . .                      |

Re:"word" data type


On Thu, 11 Jul 1996 03:31:26 GMT, cmill...@ix.netcom.com (chuck miller)
wrote:

Quote
>I am working on a program which needs to read a Turbo Pascal data
>base.  I am using Visual Basic to write the program.  VB apparently
>does not have an equivalent to the "word" data type.

A word (on the 80x86 processor) is simply a 16-bit, two-byte quantity
capable of having the values $0000 to $FFFF (0 to 65,535 decimal).  If
VB has an unsigned integer type (unsigned 16-bit type), use that in
place of word.

If VB does not have an unsigned integer type, use the int type anyway
and handle the sign yourself.

Quote
>If anyone knows how to convert a "word" field  to C I could take it
>from there.

In C, a Pascal word type may be defined as

        typedef unsigned int word;

Or, if you'd prefer not to typedef, use a preprocessor directive:

        #define WORD    unsigned int

--
Robert B. Clark <rcl...@iquest.net>
"Be wary of strong spirits.  It can make you shoot at tax collectors...
and miss." --RAH

Re:"word" data type


In article <31e4749f.1234...@nntp.ix.netcom.com>,
   cmill...@ix.netcom.com (chuck miller) wrote:

Quote
>I am working on a program which needs to read a Turbo Pascal data
>base.  I am using Visual Basic to write the program.  VB apparently
>does not have an equivalent to the "word" data type.

>If anyone can help me understand the "word" data type I will
>appreciate it.  How is it structured?  Hopefully, I can write some
>sort of conversion routine.

Word is a two byte variable in the range 0..65535.

Quote
>If anyone knows how to convert a "word" field  to C I could take it
>from there.

It is the same as unsigned int.

-----------------------------------------------
Mike Chapin
Powder River
mcha...@vcn.com
http://www.vcn.com/server/netizens/mchapin/first.html
Gillette, WY

Not the end of the earth but you can see it from
there.
-----------------------------------------------

Other Threads