06-11-2024 05:05 AM
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.
Solved! Go to Solution.
06-11-2024 08:58 AM
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.
06-13-2024 02:57 AM
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.
06-13-2024 04:00 AM
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.
For information, I work with the 2020 version of labwindows/CVI
06-13-2024 07:29 AM - edited 06-13-2024 07:48 AM
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.
06-13-2024 07:45 AM
OK I see.
I found a workaround which consists of dividing my settings into several sections and also the comments associated with each section.