我现在想把存在txt文件中的数据一下全读出来然后显示在Graph 控件上,有人说使用FileToArray可以做到,但是我怎么也做不对,程序如下:
int CVICALLBACK PsmphfCallbcak (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
double *frdata;
int n;
switch (event)
{
case EVENT_COMMIT:
FileSelectPopup ("", "*.txt", "*.txt", "外部交流电压", VAL_OK_BUTTON, 0, 1, 1, 0, file_name);
GetFileInfo ("file_name", &filesize);
n=sizeof(double);
frdata=(double*)malloc(filesize);
FileToArray ("file_name", frdata, VAL_DOUBLE, filesize/(2*n), 2, VAL_GROUPS_TOGETHER, VAL_GROUPS_AS_ROWS, VAL_ASCII);
PlotY (psmppanelHandle, PSMP_PANEL_GRAPH_WJ, frdata, filesize/(2*n), VAL_INTEGER, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);
break;
}
return 0;
}
运行的时候错误总出现在这一句:
FileToArray ("file_name", frdata, VAL_DOUBLE, filesize/(2*n), 2, VAL_GROUPS_TOGETHER, VAL_GROUPS_AS_ROWS, VAL_ASCII);
老是说 NON-FATAL RUN-TIME ERROR: "MainUser.c", line 1317, col 14, thread id 0x00000600: Library function error (return value == -1 [0xffffffff]). File not found
错误见附件:
望搞人指点!非常感谢!
|