04-20-2015 02:00 PM
I have been struggling with this issue for a few days now. I am trying to create a VI which writes some values to a file with a custom name based on the time stamp. My issue is that when I try to create a new file I get the error LabVIEW: The path is empty or relative. You must use an absolute path. I have tried to figure out why the path is empty or relative. I have looked at the write to file example that comes with labview, but I can't figure out the differnce bettwen their path and my path which would generate the error. I have attached a VI file which uses the naming protocol I want. Any help would be appreciated.
04-20-2015 02:10 PM - edited 04-20-2015 02:20 PM
Your VI works just fine here.
What text do you use for the String input? Make sure you don't use any disallowed characters.
What's the output of your "Default data directory" node? What is your OS?
(You should also set the string control to "limit to single line", but that's not the cause of the problem).
04-20-2015 02:34 PM
04-20-2015 02:50 PM
My default data directory is defined to the documents folder under LabVIEW Data. I have written that out and used it in place of Default data directory command in earlier versions as part of my troubleshooting. Here is the file path that my computer generates using the uploaded VI :
C:\Users\longwall\Documents\LabVIEW Data\test_15_04_20_1535.txt
My string input is just test right now. I am using Labview 2013 with Windows 7 Enterprise Ed.
I am glad to know that I did the right things, and in theory it should be working on my computer. I will try restarting and see if that fixes things. Maybe something has been getting stored without me realizing it which is causing the issue. Thanks.
04-20-2015 03:12 PM
It seems to be working fine now. It seems to be sensitive to some other VIs which can interact with it under certain conditions. Now that I know that my base code works, I should be able to get the rest of the quirks either solved or worked around. Thanks for your help.
04-20-2015 03:24 PM
It is not clear to me how other VIs could intereact with this under certain conditions. Would be nice to fully understand what's going on.
Also note that since you open it in "create" mode, you would get a (different) error if you run it more than once a minute. You might want to protect against that possibility.
04-20-2015 03:26 PM
I can reproduce the error if I set the value of the String control to a non existing relative path or absolute path. Absolute path cannot work anyway, but relative path works if it exists.
For example, if you set the Sting to '..\tmp' it is fine because it will point to 'C:\Users\longwall\Documents\tmp_somename.txt'.
If you go with 'tmp\' it will generate the error you are seeing, because you probably don't have the folder 'C:\Users\longwall\Documents\LabVIEW Data\tmp\'
04-21-2015 07:03 AM - edited 04-21-2015 07:16 AM
I really want it to have create/open rights and read/write for future (and I have made those changes). I was limiting it to create since it was opening existing files just fine, but the hang up was when I tried to create a new file.
As far as the interaction, I don't understand either, but I noticed that when I ran the VI in the bold face above the regular text which indicated not a path it referenced two other VIs which I had open and had been working on earlier. They were a timestamp VI which is the more complex version of what I posted since I am trying to write a note and times an event occurs. The timestamp VI is used by a second VI which is controlling a motor and when an event occurs it uses the timestamp VI to write to the file. The problem I was having was that it would not let me define a file name in the motor controller vi or in the timestamp vi. Instead it would write to a file if I had created one by hand first. So I extracted out the open/create file and was trying to see if my naming structure was wrong without having to run all the other commands. The problem was that even though my Untitled VI was not referencing the other two, the error text mentioned them. I do not understand why running this VI would cause Labview to give me an error message that reference other VIs not being run. However when I started everything fresh that error went away. Now when I run it I getting an error for possible duplicate path which is impossible since it was the first time I ran it today so the timestamp would make it unique. However, it does actually create the file.
Update: I ran the VI a few minutes later without changing anything. Litterally wrote the post above checked my email then went back to the vi window again (never closed it) and clicked run. This time I don't get the duplicate error. I really am lost as to why the same file sometimes run w/ error but other times seems to work fine.