LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

INI instrument driver and fatal run time errors

Solved!
Go to solution

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:

 

  1. The runtime error only happens during the very first Ini_Putxxx
  2. It only happens if the target INI file does not yet exist.  After the file is created with a Ini_WriteToFile, then the program will proceed with all my Put functions without any errors.

Ideas?

0 Kudos
Message 1 of 5
(3,206 Views)

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.

0 Kudos
Message 2 of 5
(3,201 Views)
Solution
Accepted by topic author ElectroLund

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?



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 5
(3,189 Views)

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!

0 Kudos
Message 4 of 5
(3,133 Views)

You were of course correct, Roberto. I had forgotten to call Ini_New() before writing values to an ini buffer.  Oops!

0 Kudos
Message 5 of 5
(3,082 Views)