Irene,
First the easy technical answer: You can call IBCLR any time, you don't need to have sent anything to the instrument first.
I noticed you posted a similar question earlier, so I wanted to try and get some clarification about what you're trying to do. The function you referred to in both posts, CNi4882Device::Clear(), is part of the Measurement Studio C++ API for GPIB. However, you mentioned that you're working in C. If you're planning to use Microsoft Visual C++ and have Measurement Studio, the set of CNi4882- classes are a good way to go. But if you're using another compiler, or are limited only to using ANSI C, or don't have Measurement Studio, that won't be an option.
In regards to your questions about error codes - by default, the C++ API's throw exceptions rather than return status codes. To check the status codes, you must first catch the exception:
try
{
CNi4882Device g("dev1");
g.Clear();
}
catch (CNi4882Exception* e)
{
int code = e.GetError();
}
Alternatively, you can call CNiException::SetExceptionMode(false) to cause the 488.2 interface to return status codes instead of throwing exceptions. If you want the check specific error codes, there are a set of error constants defined on the CNi4882 class, such as CNi4882::ErrorTimeout, ErrorBoardNotCiC, etc. You can find these in the documentation. They are defined in the file Ni4882.h. To determine exactly which error codes a function could return, you will need to correlate the C++ API's entry points to their C counterparts (i.e., CNi4882Device::Clear() in C++ to ibclr in C.) and check the help for the C method to see what error codes it can return. However, it's rare to actually need to check for specific error codes - can you tell me a little more about what you're trying to do with your error handling code?