请教大侠一个cvi程序的问题, 点击:1088 | 回复:1



everwind

    
  • 精华:0帖
  • 求助:0帖
  • 帖子:1帖 | 2回
  • 年度积分:0
  • 历史总积分:5
  • 注册:2004年4月06日
发表于:2004-05-17 16:10:00
楼主
做一个按钮,点击后可以打开文本文件数据(.txt),用了下边这个程序,可是运行起来总是说找不到文件,哪位大侠能帮看看是什么问题阿,不胜感激,,, int CVICALLBACK openfile (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { static char file_name[MAX_PATHNAME_LEN]; double *wave ; long filesize; if (event == EVENT_COMMIT) { if (FileSelectPopup ("","*","*", "Name of File to Read", VAL_OK_BUTTON, 0, 1, 1, 0, file_name) > 0) { GetFileInfo ("file_name", &filesize); /*获取文件的大小*/ wave =malloc(filesize); FileToArray (file_name, wave, VAL_DOUBLE, filesize/sizeof(double), 1, VAL_GROUPS_TOGETHER, VAL_GROUPS_AS_COLUMNS, VAL_ASCII); DeleteGraphPlot (mainpanel, MAINPANEL_GRAPH_orig_wave, -1, VAL_IMMEDIATE_DRAW); PlotY (mainpanel, MAINPANEL_GRAPH_orig_wave, wave,filesize/sizeof(double), VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED); } } return 0; }



gongkongedit

  • 精华:1099帖
  • 求助:0帖
  • 帖子:14392帖 | 54470回
  • 年度积分:0
  • 历史总积分:622
  • 注册:2008年9月08日
发表于:2004-05-20 10:50:00
1楼
int CVICALLBACK openfile (int panel, int control, int event,    void *callbackData, int eventData1, int eventData2)    {    static char file_name[MAX_PATHNAME_LEN];    double *wave ;    long filesize;    if (event == EVENT_COMMIT)    {    status=FileSelectPopup ("d:\\cvi","*.txt","*.txt,*.doc", title, VAL_OK_BUTTON, 0, 0, 1, 0, result) ;       { GetFileInfo ("file_name", &filesize); /*获取文件的大小*/    wave =malloc(filesize);    FileToArray (file_name, wave, VAL_DOUBLE, filesize/sizeof(double), 1, VAL_GROUPS_TOGETHER, VAL_GROUPS_AS_COLUMNS, VAL_ASCII);    DeleteGraphPlot (mainpanel, MAINPANEL_GRAPH_orig_wave, -1, VAL_IMMEDIATE_DRAW);    PlotY (mainpanel, MAINPANEL_GRAPH_orig_wave, wave,filesize/sizeof(double), VAL_DOUBLE,    VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);    }    }    return 0; } 你看看行不行?

热门招聘
相关主题

官方公众号

智造工程师