Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I/CW trap the exception error code in component works

I have noticed the example CW projects trap the exception error codes and display the in a message box. How do I get this to work in my CW project for C++? I also have measurement studio for C++.
0 Kudos
Message 1 of 2
(2,499 Views)
Hello

If you are using the CNi classes, you should be able to catch the exceptions using the CNiException class.

But you wont be able to do that if you are using the
CWDAQ controls with the Class Wizard generated wrappers, since these are auto generated wrappers. You should be able to catch the exceptions by using the CException class, like so

try{
m_AIPoint.SetDevice(5); //Invalid device number
m_AIPoint.GetChannels().RemoveAll();
m_AIPoint.GetChannels().Add(m_Edit, vOptional, vOptional, vOptional, vOptional);
m_AIPoint.SingleRead(&Voltage, vOptional);
m_Meter.SetValue(Voltage);
m_NumEdit.SetValue(Voltage);
}
catch(CException *e)
{
e->ReportError();
e->Delete();
}

Check the MSDN Help for the properties and methods of the
CException class for more information.

I hope this helps

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 2 of 2
(2,499 Views)