"word" data type 
Author Message
 "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.



Wed, 18 Jun 1902 08:00:00 GMT  
 "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.



Wed, 18 Jun 1902 08:00:00 GMT  
 "word" data type

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.
>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 |



Wed, 18 Jun 1902 08:00:00 GMT  
 "word" data type



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

--

"Be wary of strong spirits.  It can make you shoot at tax collectors...
and miss." --RAH



Wed, 18 Jun 1902 08:00:00 GMT  
 "word" data type



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

http://www.vcn.com/server/netizens/mchapin/first.html
Gillette, WY

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



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. The keys "-"/"+"/"*"

2. Pascal "Word" Problem

3. ""256 Color Mouse""

4. mssql uniqueidentifier causes "invalid field type"

5. Units and "type mismatch" error

6. "Invalid field type" exception

7. Spooky "Type Mismatch in Expression" problem

8. changing real type data to word type

9. "Data corruption error"

 

 
Powered by phpBB® Forum Software