1420
Keysight InfiniiVision M9241/42/43A PXIe Oscilloscopes SCPI Programmer's Guide
40
Programming Examples
{
strcat(str_out, ", ");
strcat(str_out, str_err_val);
err = viQueryf(vi, ":SYSTem:ERRor?\n", "%t", str_err_val);
if (err != VI_SUCCESS) error_handler();
}
if (strcmp(str_out, "") != 0)
{
printf("INST Error%s\n", str_out);
err = viFlush(vi, VI_READ_BUF);
if (err != VI_SUCCESS) error_handler();
err = viFlush(vi, VI_WRITE_BUF);
if (err != VI_SUCCESS) error_handler();
}
}
/* Handle VISA errors.
* --------------------------------------------------------------- */
void error_handler()
{
char err_msg[1024] = {0};
viStatusDesc(vi, err, err_msg);
printf("VISA Error: %s\n", err_msg);
if (err < VI_SUCCESS)
{
exit(1);
}
}
VISA Example in Visual Basic
To run this example in Visual Basic for Applications:
1
Start the application that provides Visual Basic for Applications (for example,
Microsoft Excel).
2
Press ALT+F11 to launch the Visual Basic editor.
3
Add the visa32.bas file to your project:
a
Choose
File > Import File...
.
b
Navigate to the header file, visa32.bas (installed with Keysight IO Libraries
Suite and found in the Program Files (x86)\IVI Foundation\VISA\WinNT\
Include), select it, and click
Open
.
4
Choose
Insert > Module
.
5
Cut-and-paste the code that follows into the editor.
6
Edit the program to use the VISA address of your oscilloscope, and save the
changes.
7
Run the program.