From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in writing Integer Data in Hex in Write Spreadsheet File

It appears that Write to Spreadsheet File forces all data to I64. Try writing an I16 or I32 array with a negative number. Format specification to 4x, 8x or whatever is ignored and you get a full completent of 16 bytes with a lot of FF's at the beginning making it I64 
Chief Scientific Officer & Ex-Head
Advanced Centre for Materials Science
Indian Institute of Technology
Kanpur 208016
Phones: +91-512-2597830, 3927830(Off), 2574628 (Res), 9336117477 (Mob)
Fax: +91-512-2597459
E-mail: sg@iitk.ac.in, sgiitk@physics.org, http://home.iitk.ac.in/~sg
0 Kudos
Message 1 of 7
(2,673 Views)
Hello sgiitk,
the write to spreadsheet file is a polymorphic VI which has three different instances. You can check this rightclicking on the icon and choose select type, there is to be seen the type double, integer and string. Select integer and doubleclick on the VI- icon to open, then you see the type of the input array is I64. Now you could change this VI to your needs, save it with another name and append it to the list in the polymorphic VI. To open the actual polymorphic VI, select Open Polymorhic VI from the context menu of the VI- icon you first placed on the BD,
Greets, Dave

Message Edited by daveTW on 02-26-2007 10:15 AM

Greets, Dave
0 Kudos
Message 2 of 7
(2,667 Views)
Hi;

it's not a bug it's a feature 🙂

Whenever you want to format numbers the formatting routine will try to leave as much digits as needed/possible. When you format I8 then 2 digits are ok, I16 needs 4 digits and so on.
You can easily test this behaviour when using the 'Array to spreadsheet string' function (it's also used inside 'Write spreadsheet file'). When saving negative integers as Hex formatted ALL digits are needed to describe the number and so you get all of them in your text file!

The only problem is: 'Write to spreadsheet file' only knows about I64. Whenever you want to save negative numbers you get 16 digits regardless of format string.
Solution:
Change the 'write to spreadsheet file' as described before or do the formatting on your own by using 'array to spreadsheet string'!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 7
(2,655 Views)

I cannot see how it is a feature.  If the input array is, I16 nothing whatsoever is gained by forcing an I64 format. You are losing resources all round. I suspect this one slipped through since unless the user is writing Hex this bug will not show up at all!

I am writing data to a file on cRIO and every byte is precious to me. Using a %4x positive numbers are 4 bytes long, but the negatives are now eating up 16 bytes every time. Of course I worked my way around using the 'spreadsheet to array function' and writing the text file as soon as I saw the problem. I could also figure out pronto that with integers LV only looks at I64.

 

 

Chief Scientific Officer & Ex-Head
Advanced Centre for Materials Science
Indian Institute of Technology
Kanpur 208016
Phones: +91-512-2597830, 3927830(Off), 2574628 (Res), 9336117477 (Mob)
Fax: +91-512-2597459
E-mail: sg@iitk.ac.in, sgiitk@physics.org, http://home.iitk.ac.in/~sg
0 Kudos
Message 4 of 7
(2,654 Views)
Hi,

before LV8 the 'write to spreadsheet file' did only know about ONE datatype: SGL! Many people complained about this.
Starting from LV8 this functions is polymorphic and knows about DBL, I64 and String. So NI already made this function more usable/versatile! And you are still complaining 😉

When you want to use this function you have to check it's behaviour. When the behaviour doesn't fit your needs you have to make your own function as described before...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 7
(2,649 Views)
Hi Gerd,
I agree with you, and it's great in LV that there are so easy ways to adapt the library functions to different needs.
Greets, Dave
Greets, Dave
0 Kudos
Message 6 of 7
(2,642 Views)
Hello Sanjay,

The way to change the datatype in this case is as follows:
  • open the I64- Instance of the polymorphic
  • Save as... with option "open additional..."
  • in the new opened VI select the VI- Properties (Ctrl+I)
  • In the category "protection" select no protection
The VI is now editable...

Greets, dave

P.S. it's better to use the forum threads than email
Greets, Dave
Message 7 of 7
(2,638 Views)