LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Help me! How can I get the same result using ANSI's fread/fwrite in 16bit and 32 bit CVI!

I have a big problem here.
I want to update my CVI3.1 version program to CVI5.01 version which run
quickly on 32 bit OS.
I work with everything fine except that the fread/fwrite command can't
get the correct result(the structure and pointer).Some String value seem to
be reasonable,but the float type value is too far from the correct value.
I think it maybe caused by the different bits of the fread/fwrite
command.I want to solve this problem urgently.
Who know this question, please do me the great favor, I will be so
appreciated.

My Email is: nirofang@hotmail.com
0 Kudos
Message 1 of 4
(3,450 Views)
Sir,
I think you need to take a close look at the file you are using these fread and fwrite to. Were you able to recompile to code in the 32 bit version without any issues? Make sure that you are reading or writing the proper number of bytes from the file, because once you compile in the 32 bit version, the source is modified to 32 bit, and I can't see that being the cause of the issue here.

Daniel McChane
Application Engineer
National Instruments
0 Kudos
Message 2 of 4
(3,450 Views)
> Sir,
> I think you need to take a close look at the file you are using these
> fread and fwrite to. Were you able to recompile to code in the 32 bit
> version without any issues? Make sure that you are reading or writing
> the proper number of bytes from the file, because once you compile in
> the 32 bit version, the source is modified to 32 bit, and I can't see
> that being the cause of the issue here.

>Thank you for your advise,Daniel:
My operating data is writen in binary mode.
Do you mean that I should redefine my structure to read,
just like define double to float? (double(16bit)==float(32 bit))
0 Kudos
Message 3 of 4
(3,450 Views)
niro wrote in message <3d926998@newsgroups.>...
> I have a big problem here.
> I want to update my CVI3.1 version program to CVI5.01 version which run
>quickly on 32 bit OS.
> I work with everything fine except that the fread/fwrite command can't
>get the correct result(the structure and pointer).Some String value seem to
>be reasonable,but the float type value is too far from the correct value.
> I think it maybe caused by the different bits of the fread/fwrite
>command.I want to solve this problem urgently.
> Who know this question, please do me the great favor, I will be so
>appreciated.
>
>My Email is: nirofang@hotmail.com
>
>

The default structure packing may be different between the two versions.
See the structure packing pragma in the _LabWin
dows/CVI Programmer
Reference Manual_. You can look at the details of the structure in the
variables window of the IDE to see if any packing bytes are added.
Another way to debug this problem is to write the same
data with each version, then use a hex editor or debug.com to look
at the first couple of records.

We did see a difference in the structure packing when LabWindows
was set up for Microsoft VC++ compatibility vs. Borland C/C++.
We had to set up for Borland to make the structures compatible with
an embedded system we were communicating with.

Please feel free to email me you have any questions.
Regards,
Reed.


--
Reed Blake
Beta Technology
Industrial and Scientific Computing
0 Kudos
Message 4 of 4
(3,450 Views)