Showing results for 
Search instead for 
Did you mean: 

Reading and writing HEX data to and from ini file

Go to solution


I'm having difficulty writing and reading back hex data to and from an ini file. I don't think I'm writing the data correctly hence the incorrect data that I was reading. What is correct way to store or write hex data to ini file and read it back correctly?  I have attached a vi I created to read the file.  See also the screenshots of the ini file data.

Any suggestion will be appreciated.






Download All
0 Kudos
Message 1 of 6



@SolPS wrote:

What is correct way to store or write hex data to ini file and read it back correctly?


Any suggestion will be appreciated.

There is no "correct way", there only is the way "fulfilling your requirements"…


I think the way you stored those data is quite ok. Which results do you get when you read your INI file?


Comments on the VI:

  • Why do you open the INI file in each iteration, but close it only once after the loop? (You only need to open once before the loop!)
  • Why do you need two loops? Why not create the key inside the second loop???
Best regards,

using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6

Hi GerdW,

I'm trying to convert the data that I read from the file to an unsigned 16bit integer before I writing it to my serial port device. The problem was that I get an error at the "scan from string" function. When I tried to use the "Hexadecimal string to number" function in the loop so I can obtain a u16 array at the end of the loop iteration, all the output array values turned out to be zero. That was why I felt I was doing something wrong.


Regarding opening the INI during each iteration, that was an omission.  It is just a troubleshooting VI that I was using to look at my data values. It was an oversight. I used the first loop to generate the keys. I copied data into the control.

0 Kudos
Message 3 of 6

Do you know why I would be getting zeroes in the output of a u16 array?

0 Kudos
Message 4 of 6
Accepted by topic author SolPS

If your Scan from String function is erroring out, look at its inputs, because your format code is correct.


I believe your issue is that your "Keys" array (which is actually the Default Values array) has a typo- there's a space before the 0x0003. When that space gets fed into Scan from String, it errors out because you're telling it to look for the EXACT string "0x" at the start. Instead, it finds " 0x" at the start, which is not what you need.

Heads up! NI is moving LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 5 of 6

Hello BertMahan,

You are correct. That was the problem. Thanks so much..

0 Kudos
Message 6 of 6