NI LabVIEW,CVI,数据采集等产品讨论区

取消
显示结果 
搜索替代 
您的意思是: 

如何在LabWindows CVI不弹出对话框就可以创建文件?

在LabWindows CVI中,在进行实时存储时,如何不用弹出对话框就可以根据时间命名文件并创建这个文件?
0 项奖励
1 条消息(共 8 条)
5,140 次查看
Which function are you using? There should always be a way to auto specify the name,  acturally, I think a pop up message box is more difficult than the auto naming, except you are using a ready made function.
Best Regards

Hu Yu
0 项奖励
2 条消息(共 8 条)
5,120 次查看

代码如下: 

GetCurrentDateTime(&currDateTime);            //获取系统时间

FormatDateTimeString (currDateTime, DATETIME_FORMATSTRING, NULL, 0);   //格式化时间格式
bufferLen = FormatDateTimeString (currDateTime,
              DATETIME_FORMATSTRING, NULL, 0);         

dateTimeBuffer = malloc (bufferLen + 1);                      //根据指定大小分配空间
FormatDateTimeString (currDateTime, DATETIME_FORMATSTRING,
                      dateTimeBuffer, bufferLen + 1 ); 
strcpy(DirAttachPath, dateTimeBuffer);
strcat(DirAttachPath, ".tdms"); 
if(FileSelectPopup ("", DirAttachPath, "*.tdms","要保存的文件名",
                 VAL_SAVE_BUTTON,0,0,1,1, sFile ) >0) 

{}

如何不弹出对话框就直接创建文件? 

 

0 项奖励
3 条消息(共 8 条)
5,108 次查看

用 FileSelectPopup 当然会弹出对话框了。

如果是要创建TDMS文件用 TDMS_CreateFile 函数就可以了。直接指定文件路径等信息就可以创建了。在 TDM Streaming Library下面

欢迎参加 LabVIEW天下会 详见www.GSDzone.net
0 项奖励
4 条消息(共 8 条)
5,103 次查看

zx158 wrote:

代码如下: 

GetCurrentDateTime(&currDateTime);            //获取系统时间

FormatDateTimeString (currDateTime, DATETIME_FORMATSTRING, NULL, 0);   //格式化时间格式
bufferLen = FormatDateTimeString (currDateTime,
              DATETIME_FORMATSTRING, NULL, 0);         

dateTimeBuffer = malloc (bufferLen + 1);                      //根据指定大小分配空间
FormatDateTimeString (currDateTime, DATETIME_FORMATSTRING,
                      dateTimeBuffer, bufferLen + 1 ); 
strcpy(DirAttachPath, dateTimeBuffer);
strcat(DirAttachPath, ".tdms"); 
if(FileSelectPopup ("", DirAttachPath, "*.tdms","要保存的文件名",
                 VAL_SAVE_BUTTON,0,0,1,1, sFile ) >0) 

{}

如何不弹出对话框就直接创建文件? 

 


 

Well, you can notice the FileSelectPopup function? This is why there will be a pop up message box, and I think this code have nothing to do with creating a file, you can just find the function which have something to do with creating files, specify a file name with dates or time or anything else, just delete this function
Best Regards

Hu Yu
0 项奖励
5 条消息(共 8 条)
5,100 次查看

哪个函数可以直接创建呢?

0 项奖励
6 条消息(共 8 条)
5,096 次查看

如果是写普通的文本或者二进制文件,直接用 OpenFile() 即可,参数选择VAL_READ_WRITE 就可以创建文件了。比如:

OpenFile ("c:\\1.txt", VAL_READ_WRITE, VAL_OPEN_AS_IS, VAL_ASCII);  

 

写TDMS用我前面回帖里说的 TDMS_CreateFile

 

int TDMS_CreateFile (const char *File_Path, TDMSFileFormat File_Format, const char *Name, const char *Description, const char *Title, const char *Author, TDMSFileHandle *File);

 

这两个都不会弹出窗口,直接可以创建

欢迎参加 LabVIEW天下会 详见www.GSDzone.net
0 项奖励
7 条消息(共 8 条)
5,083 次查看

创建文件可以用下面的函数实现:

 下面的代码是在工程目录下创建一个文本文件,你用的是TMDS的文件格式只是在写文件内容时会有区别。

 

 

 char testfile[STRLEN];      /*文件名*/   
 char suffix[20] = "00.txt";   

 int    number=1;
 FILE *pftest; 

 

    GetDir (filename);
    Fmt(suffix,"\\OUTPUT\\CN07-%d.txt",number++); 
    strcat(filename,suffix);
    pftest=fopen (filename,"w+");

    fprintf( pftest,"SwitchCode 7\nSetImagePath C:\\CN07");

    fclose(pftest);

 

 

这个时候在工程目录下的OUPUT文件夹里会有一个为CN07-1.TXT的文件,打开文件里面会有SwitchCode 7 和SetImagePath C:\\CN07两行文本了。

 

 

0 项奖励
8 条消息(共 8 条)
5,017 次查看