LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Update file name

Hi Mah,

Glad to see that there was progress.  I will review your questions in order to understand what you are trying to achieve.

"I got it to work, however it only made one new file, with a number 1 at the end."  It (should) creates one new file every time the vi is run.  Do you intend to create more than 1 file when running the vi (calling it)?  You could use the vi as a sub-vi and call it more than once from the main vi.  But if you describe how this should function, then I can provide more accurate suggestion(s).

"I keep getting an error dealing with the "Scan from String" function I think."    I would have to see this portion of your code.  Can you post it or at least that portion as a jpg attachment?   

"Also it seems to not work if the file has already been created, it will not create or update the file for me."  It should create a new file everytime it is called or run.  Can you post this portion of your code (or the entire vi)? 

"Also I can only seem to get this to work when using the directory, not selecting individual files."  Yes, this is actually what it does.  I didn't realize that you wanted the option to select a file at run-time.  😉

"Is it possible to "hard-wire" a path and file name to somewhere in the vi (able to change via the front panel)?"    Absolutely.  Can you describe the how & why you want to select a particular file? I thought that you wanted to look at a directory and create a new file having the same name but with the next number appended to it.  Can you show me an example of actual file names?

"THen that would be the file to update and whatnot when saving?"  So you want to select the file after it has been created... is that so?  Do you actually want to select the new filename or should it be selected by default?  Do you simply want to see the new filename in use?  Or do you actually want to browse and select the new file manually?

Sorry to have so many questions, but I am trying to capture a better understanding of what you wish to achieve.

Ray

😄

Message 11 of 94
(3,004 Views)
Thanks again for replying.
 
I've gone back and tried again to work with the original vi you had posted and have made some progress over what I had posted before, but still have questions.
 
I have gotten the original vi you posted to work!  However when it first runs I get a pop-up error message (Error 85) from the Scan from String.  But the new file is still created and the name is updated (filename1 for example, I created a dummy file (text file) to test it out).  I then can rerun the vi and get new files.  I do this until the filenames reach 10 (filename 10 for example).  On this run I get an error in the error cluster box on the front panel - code 10, New File in new filename.vi.  It won't let me update the files after this, but the vi did/does work.
 
Now let me see if I can explain what I'm (or what I'm asked to do and need help with!) looking for.  Basically for right now I'd like to hardwire the file name and path of the file that my data would be saved to.  This would be controlled via the front panel.  The file itself would be updated each the  vi is run and the data is chosen to be saved (I have my write characters to file vi inside a case structure which allows for running with saving or without).  So if I ran the main vi and saved data and the file was "testdata1" and then 5 minutes later ran the vi again for saving (after stopping) it would be "testdata2".  This data would be saved in a folder specified in the front panel "hardwire" window.  (I believe this is what we want for right now, not the pop-up window saving feature.)  The vi would take the file specified and update that name.  Originally this file would not be in the directory specified, it is created when the vi is run and data is first saved.  It will be new data with each file (hence my need to update the file names automatically). 
 
Ultimately I'd like to wire this into the "write characters to file vi" since that is what I use to save my data.  I was trying to figure out how this would be but first I need to just get the update down and then I can worry about that.  (I would have to ask for your help with that also).
 
For right now, I don't think I need the pop-up window, although my co-workers may wish to go in this direction later.  If that is the case, I'll let you know, but for right now I'm going with the "hardwire" approach.  Taking a name specified and updating its name each time the data is saved. 
 
Again thanks for your help, I really appreciate it.  I hope I've been able to explain myself a bit better, if not, just let me know, and I'll try again!
 
 
 
 
Using Labview 7.0 and 2010 SP1 with Windows XP and 7.
0 Kudos
Message 12 of 94
(3,000 Views)
Just a small note.  If you use "path to array of strings" instead of "path to string", you do not need to worry about the "\" and the concantenate.  Tack the filename on the end of the array and convert it back into a string.  Handy if you are ever making cross platform applications.
0 Kudos
Message 13 of 94
(2,994 Views)

Hi Mah,

I think I understand what you want to do.  So basically hardwire the path instead of browsing for it.  Since your co-workers like the feature, a switch can be added to choose from the two.  I will try to modify the vi tonight and post it in this thread.

It is possible that the error that you get (error 85) is because you are scanning a path instead of a string.  What is the color of the wire?  I will do a search on error 85.

Ray

Message 14 of 94
(2,980 Views)

Hi Mah,

Here is what I found on Error 85:

To find the meaning of the error code meaning, you can right-click on a front-panel error cluster and select the "explain error" option to see all the known causes of the error. Use an error cluster on the Front Panel, set status to Error and code to 85, right click on it, and select "explain error".

"Error 85 occurred at an unidentified location
Possible reason(s):
LabVIEW:  Scan failed."

 It appears that you might be trying to use the "Scan From String" function with input data that does not match the format string, maybe feeding in a path, for instance...   If that is the case, simply convert the path to string first.

Ray

🙂

Message 15 of 94
(2,983 Views)

Hi Ray, thanks again for replying.  I had found the same information on the errors I was getting.  I'm still not sure why I am getting them.  I have not altered your wiring in anyway, I'm just trying to see if the vi you posted would work.  I simply created a sample text file wit hthe word "hello" in it.  Maybe that is the problem.  The name of the file was simply "filename".  I'm not really sure what's going on or how to proceed exactly, I mean i think it's close but I'm just not sure getting it to work right, with finding out why I'm getting these errors. 

If you could post the modifed vi you had mentioned I'd appreciate it. 

 

Thanks again for your help.

Using Labview 7.0 and 2010 SP1 with Windows XP and 7.
0 Kudos
Message 16 of 94
(2,962 Views)

Hi Mah,

Attached is an updated version.  It has the features you were looking for.

The original error was due to the fact that the filename did not contain a numeric value nor an extention.  This one fixes that, so you can actually use "filename" as a name or "filename.txt" or "filename10" or "filename11.txt".  It will work for all these conditions.

HOWEVER...  You must fill in a leading filename in control panel and set the switch to select a hard-coded or run-time folder location.  If it is hardcoded, then a folder name MUST be entered. 

I think the rest is straight forward...  😉

Hope this one helps.  Try running it as is then placing it within your vi.

Ray

 

Message 17 of 94
(2,945 Views)

Hii,Joe,

             Thanks for the solution, but i am still confused, will it acept .xls file?

             HOWEVER...  You must fill in a leading filename in control panel, i cant understand this line,can u explain pls.... whenever switch is at the Hardcoded folder side, it always generate anerror of type,New File in new filename.vi in the error out dialog box, so can you explain me about this things!!!!!

Thanks,

Nishant

Message 18 of 94
(2,925 Views)


Thanks for the solution, but i am still confused, will it acept .xls file?

HOWEVER...  You must fill in a leading filename in control panel, i cant understand this line,can u explain pls....

whenever switch is at the Hardcoded folder side, it always generate anerror of type,New File in new filename.vi in the error out dialog box, so can you explain me about this things!!!!!


Hi Nishant,
 
Yes, the last example (maybe i should give rev numbers to the examples 😉  ) does support any filename with any extention.  The example is to support these types of format (and will append the number in the following manner):
 
filename                                              enumerated new filename
 
name                                                  name1, name2, ... name_n_
name1                                                name2, name3, .... name_n_          (where _n_ is actually a number)
name.ext                                            name1.ext, name2.ext, ..., name_n_.ext  ( where ext is any extention type)
name2.ext                                          name3.ext, name4.ext,...., name_n_.ext
 
"name" can be anything you want.
 
There is an input on the front panel called "leading filename", this is where you type "name".  It is the portion of the filename that leads where the number is.   You should also create at least 1 basic filename. So if you created 1 file whose name is "my_example8.xls", then the filenames being created would start with "my_example9.xls".  In this case, the leading filename is "my_example".  I guess I could have given some intelligence to the filename scan, but the problem was "what happens if the leading filename contains a number, such as this example which is also supported?"
 
example with a leading filename having a number:
 
"my_filename0990.xls"  with leading filename "my_filename0990".  This will give you "my_filename09901.xls", "my_filename09902.xls", and so on.  I have not tried leading filenames where the incrementing number is in between the name, so I will say that it does not support a leading filename such as below (but you can try it 😉  :
 
"my_embedded_filename.txt",  with the leading filename "my_embedded_file", which might give... "my_embedded_file1name.txt"... << unsupported...  😄
 
If you use the HARDCODED folder option, you MUST fill in manually the location of where the files will reside, such as:
C:\my_folder\
You simply type it in the Front Panel file folder input (control).
 
Please note that the vi does not have a create folder option... I guess that would be the next step into it's evolution.  Maybe I can do it if I have the time and repost the example... But you can easily do this part. 
 
 
Let me know how it goes..
 
Regards,
 
Ray
Message 19 of 94
(2,917 Views)

Hiii, Ray

               Thanks for the explaination, and it is working quite well, the problem is only that, it is not generating the file with the extension type, mean suppose i am giving the .xls in the extension box, it is not generating the xls file, (Data1.xls), it only creates the file data1, which doesnt have any specific type, can you please check this out?? and suppose i am writing the file with ext in the file name box(data.xls) it will generate the data1.xls1, which also doesnt have the specifib type. so please resolve this, if you can!!!!!!!!!

Thanks,

Nishant

Message 20 of 94
(2,904 Views)