LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Ini file Ini_WriteToFile function returns error code -104

Solved!
Go to solution

Hi, 

 

I have an issue with the Ini_WriteToFile function.

The Ini_WriteToFIle function returns an error code -104 when the size of comments in the file header exceeds a certain size (around 3 kb).

 

Has anyone come across this issue before ?

 

I copied an example of an ini file.

0 Kudos
Message 1 of 6
(8,609 Views)

It has never occurred to me to deal with a .ini file with such a great number of comments so I never faced the error you get.

Since the code for this instrument is public you could try to step into it and see where the error arises. To do so load the instrument in Instrument menu (unloading it from library menu if you are doing so) and then execute Instrument >> Edit menu function, select IniFile instrument and press Attach and Edit Source button.

After doing so you can open the source code and place a breakpoint inside Ini_WriteToFile function, next execute the code step by step and see what happens.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 6
(8,577 Views)

I had the idea of testing your .ini file inside the sample ini application that ships with CVI (<CVISamplesFolder>\samples\toolbox\ini.cws) and could read the file, add two items and save it without getting errors. I am attaching the modified .ini file: filecompare gives no difference except for the items added.

 

You may want to investigate further on your environment to understand where exactly the error arises since apparently it is not depending on the content of the ini file.

 

Tested in CVI2017 FDS.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 3 of 6
(8,542 Views)

I'm surprised that editing then saving my ini file works for you. I finally managed to debug the Ini_WriteToFile(..) function and obviously an error is thrown as soon as the size of the comments is greater than 3072 (1024 * 3) characters in the Ini_WriteToOutput(..) function following the call to the UTF8StrToMBStrBuf(...) function.

 

aharel_0-1718269151325.png

 

aharel_1-1718269170375.png

For information, I work with the 2020 version of labwindows/CVI

0 Kudos
Message 4 of 6
(8,537 Views)

It's no surprise if you consider that UTF8 support was introduced in CVI2020! IniFile instrument must have seen a major revision in this occasion, since the function you pointed us to simply doesn't exist in 2017.

But anyway the whole size of comments in your file is way larger than 1024 characters that should be limiti of my release; furthermore, IniFile instrument treats content in lines so some research more has to be made I suppose to fully understand this situation.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 5 of 6
(8,514 Views)
Solution
Accepted by topic author aharel

OK I see.

I found a workaround which consists of dividing my settings into several sections and also the comments associated with each section.

0 Kudos
Message 6 of 6
(8,509 Views)