LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

INI Error code -5003 in Ini_WriteToFile

Solved!
Go to solution

Hello,

I have code deployed on multiple machine. Recently one of machine started giving problem while writing to ini file.

Upon investigation error code returned by WriteIni is -5003.

Error explanation "-5003: Could not generate an unused temporary file name in the in the same directory as the output file." 
Can somebody explain what -5003 means? And why this would happen to particular machine?

 

The func that reports the error is below

Appreciate response.

 

Regards

Girish

 

 

void IniWriteRecord (double CurTemp)
{
int status;
char TimeDate[50];
IniText RecordIni;

RecordIni = Ini_New (0);
status = Ini_ReadFromFile (RecordIni, szInirecordpath);

if (status < 0)
printf("IniWriteRecord: Error writing to Reading from record file\n");

sprintf (TimeDate, "%s %s", GetDateStr (),GetTimeStr ());
status = Ini_PutRawString (RecordIni, "RecorderAddOn", "Version", PROGVERSION);
status = Ini_PutRawString (RecordIni, "RecorderAddOn", "LastUpdate", TimeDate);
status = Ini_PutDouble (RecordIni, "RecorderColumns", "temperature", CurTemp);
status = Ini_PutInt (RecordIni, "RecorderColumns", "tstable", StableFlag);
//status = Ini_PutInt (RecordIni, "RecorderColumns", "tstable", 1);
status = Ini_PutInt (RecordIni, "RecorderColumns", "tcycle_stopped", AbortSlope);
status = Ini_PutInt (RecordIni, "STATUS", "CHAMBER_ON", gStatusChamberOn);
status = Ini_PutInt (RecordIni, "STATUS", "CYCLE_RUNNING", gStatusCycleRunning);
status = Ini_PutInt (RecordIni, "STATUS", "MAINTENANCE", gStatusMaintenace);
status = Ini_PutRawString (RecordIni, "STATUS", "TESTRUN_NUMBER", gStatusTestrunNumber);
status = Ini_WriteToFile (RecordIni, szInirecordpath);

if (status < 0)
printf("IniWriteRecord: Error writing to Record File Error Code: %d\n", status);

if (strlen (szInirecordpath2) > 3)
{
status = Ini_WriteToFile (RecordIni, szInirecordpath2);
}
Ini_Dispose (RecordIni);
return;
}

 

0 Kudos
Message 1 of 4
(2,691 Views)

The source code for the IniFile instrument is available in <cvifolder>\toolslib\toolbox; as you can see there, Ini_WriteToFile creates a temporary filename in the same folder as the output file, writes to that file and if write is successful renames the temp file as the regular file. This is to prevent damaging the original file and guarantees that you always have a correct copy of the .ini file even in case of errors. This procedure is explained in the help for CreteAndOpenTemporaryFile that I suggest you to read.

In your situation, you may have some reason for the program not being able to delete the temporary file once created: the function can create up to 1000 files and then reports error -5003. I suggest you look into the target folder, where you should find several files named "ini$$xxx.cvi" with xxx from 0 to 999.



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 4
(2,651 Views)
Solution
Accepted by topic author Girish_B

Roberto:

Thanks for the reply. I did check the target folder for temp files but couldn't find any.

I did get suggestion to delete windows temp files so ran disk clean-up which resolved the issue.

 

Girish

0 Kudos
Message 3 of 4
(2,634 Views)

Ok good to know.

I'm happy you solved your problem even if it's not clear to me how Windows temporary files can affect the creation of a regular file in a folder, but anyway... I'm taking note of it in case I have the same problems.



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 4 of 4
(2,592 Views)