double table[100][100];
char str[1000];
char string[1000];
int CVICALLBACK ok (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
FILE *fp;
char str1[4],str2[4],str3[4],str4[4],str5[4],str6[4],
str7[4],str8[4],str9[4],str10[4],str11[4],str12[4];
int i;
char *fileName;
char projectDir[MAX_PATHNAME_LEN];
char fullPath[MAX_PATHNAME_LEN];
switch (event)
{
case EVENT_COMMIT:
fileName="txt.txt";
GetProjectDir(projectDir);
MakePathname(projectDir,fileName,fullPath);
fp=fopen (fullPath, "r");
for(i=1;i<32;i++)
{
fseek(fp,0+37*(i-1),0);
fread(str1,2,1,fp);
fseek(fp,3+37*(i-1),0);
fread(str2,2,1,fp);
fseek(fp,6+37*(i-1),0);
fread(str3,2,1,fp);
fseek(fp,9+37*(i-1),0);
fread(str4,2,1,fp);
fseek(fp,12+37*(i-1),0);
fread(str5,2,1,fp);
fseek(fp,15+37*(i-1),0);
fread(str6,2,1,fp);
fseek(fp,18+37*(i-1),0);
fread(str7,2,1,fp);
fseek(fp,21+37*(i-1),0);
fread(str8,2,1,fp);
fseek(fp,24+37*(i-1),0);
fread(str9,2,1,fp);
fseek(fp,27+37*(i-1),0);
fread(str10,2,1,fp);
fseek(fp,30+37*(i-1),0);
fread(str11,2,1,fp);
fseek(fp,33+36*(i-1),0);
fread(str12,2,1,fp);
SetTableCellVal(panelHandle,PANEL_TABLE,MakePoint(1,i),str1);
SetTableCellVal(panelHandle,PANEL_TABLE,MakePoint(2,i),str2);
SetTableCellVal(panelHandle,PANEL_TABLE,MakePoint(3,i),str3);
SetTableCellVal(panelHandle,PANEL_TABLE,MakePoint(4,i),str4);
SetTableCellVal(panelHandle,PANEL_TABLE,MakePoint(5,i),str5);
//在运行时,从txt调用的数据从str6--str12存在问题,读不到table中,如果删除了就可以读出前面五个//
SetTableCellVal(panelHandle,PANEL_TABLE,MakePoint(6,i),str6);
SetTableCellVal(panelHandle,PANEL_TABLE,MakePoint(7,i),str7);
SetTableCellVal(panelHandle,PANEL_TABLE,MakePoint(8,i),str8);
SetTableCellVal(panelHandle,PANEL_TABLE,MakePoint(9,i),str9);
SetTableCellVal(panelHandle,PANEL_TABLE,MakePoint(10,i),str10); SetTableCellVal(panelHandle,PANEL_TABLE,MakePoint(11,i),str11);
SetTableCellVal(panelHandle,PANEL_TABLE,MakePoint(12,i),str12);
}
fclose(fp);
break;
}
return 0;
}
int CVICALLBACK graphdd (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{ switch (event)
{ case EVENT_COMMIT:
SetRange(panel,PANEL_SCALE,EVENT_COMMIT,0,0,0);
DeleteGraphPlot(panel,PANEL_GRAPHDD,-1,VAL_IMMEDIATE_DRAW);
PlotWaveform(panel,PANEL_GRAPHDD,table,100,VAL_DOUBLE,1,0,0,1, VAL_THIN_LINE,VAL_EMPTY_SQUARE,VAL_SOLID,1,VAL_RED);
WaveformGraphPopup(string,str,1,VAL_CHAR,1,0,0,1);
//用PlotWaveform和WaveformGraphPopup这两种函数我都没显示出来//
break; }
return 0;
} |