Click or drag to resize

ReturnOnError Macro

Returns from the current function using the supplied status parameter as the return value, if that parameter represents a failure status.

#define ReturnOnError(status)
Parameters
status

[in] ViStatus variable to test.

Remarks

This macro is useful for organizing a series of function calls that use ViStatus values as their return codes. It allows code to be written more "linearly", as opposed to using a series of nested if-else constructs.

Example

The following example demonstrates use of the ReturnOnError macro.

C++
ViStatus _VI_FUNC acme4321_ConfigureSweep(ViSession Vi, ViReal64 StartFrequency, ViReal64 StopFrequency)
{
    // ...

    auto status = VI_SUCCESS;

    status = viPrintf(GetVisaSession(Vi), "CONFIG:SWE %0.15lg,%0.15lg\n", StartFrequency, StopFrequency);
    ReturnOnError(status);

    // ...
}

Download a complete CHM version of this documentation here.