03-28-2013 12:31 PM
Hey everyone, I'm experimenting with the INI instrument driver and running into a fatal run time error. Here's what I know so far:
Ideas?
Solved! Go to Solution.
03-28-2013 02:18 PM
I found my own solution to this. It would appear that te Ini_WriteToFile function will not create the INI file if it doesn't already exist, much like OpenFile will. So instead, I just do an initial check with the FileExists function and then create with the OpenFile (and not forgetting to immediately CloseFile).
Then I can Ini_PutString to my heart's content.
03-29-2013 03:05 AM - edited 03-29-2013 03:08 AM
Are you sure about that? I just tried calling these functions in the Interactive Execution window without errors (the destination file wasn't there before the call and has been created without errors):
#include "inifile.h" static int error = 0; static IniText T = 0; T = Ini_New (0); Ini_PutString (T, "General", "Item 1", "Test string"); Ini_PutInt (T, "General", "Item 2", 123); Ini_PutDouble (T, "General", "Item 3", Pi ()); error = Ini_WriteToFile (T, "C:\\test.ini"); Ini_Dispose (T);
Ini_PutXX functions do not make any disk access, they work entirely in memory; the only functions where the instrument accesses the disk are Ini_WriteToFile and Ini_ReadFromFile. Which error are you receiving? Can you post a sample code that exhibits the error?
04-03-2013 08:10 AM
Hmm, well that's interesting. I will try to revisit this soon. For now, I need to proceed with my clunky work-around.
Thanks, Roberto!
04-10-2013 11:25 AM
You were of course correct, Roberto. I had forgotten to call Ini_New() before writing values to an ini buffer. Oops!