LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve String Error code for Reading/Writing .ini Style Files

Solved!
Go to solution

Is there a way to retrieve the error string associated with the functions from the 'Function Tree, Reading/Writing .ini–Style Files Control', such as GetGeneralErrorString{} does for the other LabWindow's libraries?

Example, the function Ini_ReadFromFile() can return an error that is -1 to -999 from userint.h or -50000 to -5999 from toolbox.h. Does GetGeneralErrorString translate these to a string or some other function call that may be similar?

 

Thanks

0 Kudos
Message 1 of 8
(4,129 Views)

yes, you can use GetGeneralErrorString ( ini_status )

0 Kudos
Message 2 of 8
(4,104 Views)

Thanks for the reply. It seems GetGeneralErrorString will retrieve an error message but not the correct one relating to .ini style function calls. Take for example 'MakePathname'. When I put in a path name that is over 260 chars I should be getting back an error message something relating to 'Resulting pathname longer than 260 chars.' as stated in the LabWindows/CVI help documentation. Instead GetGeneralErrorString returns a string that says 'The system Font could not be loaded'.

0 Kudos
Message 3 of 8
(4,090 Views)

hm, I would assume that this is because the Utility library (MakePathname) is not in the list of supported libraries

0 Kudos
Message 4 of 8
(4,087 Views)

So my original question still stands.

0 Kudos
Message 5 of 8
(4,084 Views)

But how is MakePathname related to IniFile instrument? The first one pertains to the Utility Library and has its own error codes list, independent from IniFile instrument. And as Wolfgang already mentioned, the Utility library is not covered by GetGeneralErrorString.



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 6 of 8
(4,079 Views)

So there is no way to get an error string from the returned status of the function MakePathname()?

 

Yea sorry I got tripped up including .ini file stuff.

0 Kudos
Message 7 of 8
(4,073 Views)
Solution
Accepted by topic author atomic928

You can write your own function for returning the correct error string for the function; just as an example, I have developed this one:

char * CVIFUNC ET_GetULibFileIOErrMsg (int error)

// Descriptive messages for errors in File Utilities class in Utility Library
{
	switch (error) {
		case 0:		return "Success";
		case -1:	return "One of the path component not found";
		case -2:	return "Resulting pathname longer than 260 chars";
		case -3:	return "General I/O error occurred";
		case -4:	return "Insufficient memory to complete operation";
		case -5:	return "Invalid path";
		case -6:	return "Access denied";
		case -7:	return "Specified path is a directory, not a file";
		case -8:	return "Disk is full";
		case -9:	return "New file already exists";
		default:	return "Unknown error";
	}
	return NULL;
}

The Utility library is a complicated beast that covers a lot of different areas; the majority of functions return no error information, while others have error codes partially overlapping; for this realson, it is not possible to have a single function that covers all items in the library. The library itself only offers a similar facility for functions related to multithreading (CmtGetErrorMessage).

 



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 8 of 8
(4,061 Views)