LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

promt for new file name when exist

Hello,
 
    I am using "write charaters to file" for writing data to a file.  When a file exists,  a dialogue apears for "Replace" and "Cancel" option. My question is, How can I have it third option of prompting for a new file name when a file always exists?
  Thanks.
 
Wei Tong
LV 7.1
0 Kudos
Message 1 of 12
(4,954 Views)
Use the LabVIEW function to ask for a filename.  Use the file exists? connector to see if it exists.  If so, have it display a dialog box saying so and loop back to the filename dialog box again.
 


Message Edited by Ravens Fan on 04-13-2008 04:58 PM
0 Kudos
Message 2 of 12
(4,942 Views)
Now, the problem is :
My program automatic creates a file name and path ahead of saving the data. II connected this path to the File dialog's start path before "write characters to file.vi".  But it always pop up a dialog even the file doesn't exist because "File dialog.vi" start path only consider the directory not a full file path. How to escape this dialog if the file doesn't exist.


Message Edited by weitong on 04-13-2008 05:24 PM
0 Kudos
Message 3 of 12
(4,934 Views)
Here is the picture of my program.
0 Kudos
Message 4 of 12
(4,933 Views)
I am wondering, why all of the writing data to file VIs have "replace" or "cancel" option but do not have the option for "new file name" when the iniatial file exists?
 
Wei Tong
LV 7.1


Message Edited by weitong on 04-13-2008 06:23 PM
0 Kudos
Message 5 of 12
(4,922 Views)
I had a hard time finding that particular file dialog function on my LV 8.5.1 system.  It looks like it is an old 7.1 function.  When I finally did find it, it wouldn't run.  But I did see that it has an input for select mode.  Unwired, it's default is existing files.  Create a constant and select new or existing.


Message Edited by Ravens Fan on 04-13-2008 07:34 PM
0 Kudos
Message 6 of 12
(4,914 Views)

Thanks.

I know that. By default, it is "new or existing file". My question is, the "start path" of this file dialog is a directory where you choose/create a file, not a file you can control.

My situation is, I have had that file name created in the beginning of my program depending on the source data file name. I cannot use this file dialog,  because it cannot work with a full path including the file name.

I hope my description is clear.

0 Kudos
Message 7 of 12
(4,903 Views)
Actually, the default for that function is "existing".
 
If you are programmatically creating the name, then I guess you don't want to use a file dialog at all.  ??  Use Check if File or Folder Exists function in the File I/O/Advanced File Functions palette.
 
If you still want to use the dialog, then you can parse out the file name from the path and feed the file name into "default name" connector of the file dialog.


Message Edited by Ravens Fan on 04-13-2008 11:32 PM
0 Kudos
Message 8 of 12
(4,900 Views)

It's a pity that there is no that " Check if File or Folder Exists.vi " with LV7.1.

I use the source data file name to create a new file name (add a suffix) just in the beginning when I read the source file. After analyzing, I need to save the result with the new file name. Somtimes, from the same source data, I need to change some conditions to generate another result (This happens occasionaly).  Then I need to consider whether the file exists or not. and If existing, replacing it or creating a new file. The "write characters to file.vi" can tell you whether a file exists, but its dialog only has "replace" and "cancel" option.

Actually, I can set an indicator which shows tthat the file name has been used for saving data once, then I need to programmatically create another new name.

Anyway, Thank you.

I will try other method.

 

Best

 

Wei Tong

0 Kudos
Message 9 of 12
(4,888 Views)
Hi Wei,

in LV7.1 you can use "File/Dir information" (or similar) to get data about files - when you receive an error you know that file doesn't exist and so you have your "Check if File or Folder Exists.vi" also in LV7.1Smiley Wink


Message Edited by GerdW on 04-14-2008 09:41 AM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 12
(4,881 Views)