LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

open file returns error 1 for relative path

Hello,
When I am trying to find open a file with "Open File" or "File/Directory Info" and use a relative file path (name) (e.g. "abcd.txt"), these functions return error 1 instead of error 7. What is wrong?
Sincerely,
Albert Lysko
0 Kudos
Message 1 of 6
(3,231 Views)
Open file wont take a relative path.
It only takes the full path which you can construct yourself by doing some conversions...
0 Kudos
Message 2 of 6
(3,220 Views)
Thank you for the work-around.

Then, I have 2 questions:
1) What is the reason for not being able to open a file with relative path?
2) What happens with the path obtained from "Close File" - it is "not a path"?
0 Kudos
Message 3 of 6
(3,210 Views)
Dont know about questions one and two is confusing me.

Using VI supplied (the one I modified) it now requires a relative path with no starting slashes.
If file is chosen correctly, the open file will work and close also returning the full path actually
used...
0 Kudos
Message 4 of 6
(3,204 Views)
about the 2nd question - I think that was my mistake

about the 1st question - Did the function open file work this way in the previous versions of LabVIEW? To the engineers from NI - what is the logic behind disallowing relative path specification for "open file"???

Thank you.
Albert Lysko

PS
To be honest, Matlab is so trouble-free as it comes to file handling compared to LabVIEW's functions.
0 Kudos
Message 5 of 6
(3,201 Views)


@lysko wrote:
about the 1st question - Did the function open file work this way in the previous versions of LabVIEW? To the engineers from NI - what is the logic behind disallowing relative path specification for "open file"???

Thank you.




The concept of allowing relative path names to file functions is not a very clean one. It is based on the assumption that there is some hidden global variable specifying the "current directory". While Windows does do that (which IMO is a historical ballast from DOS days) it is not a concept easily translated to other operating systems.
Command shells have such a concept but programming APIs often not. Just consider the implications for an OS of maintaining current directories on a per process basis, which Windows does bother to do, but no other OS as far as I'm aware. LabVIEW as multiplattform environment has to make sometimes some decisions as to what not to support, because it can't be easily emulated on other platforms.

For me the concept of relative paths for file functions is confusing at least. Depending on other operations you may have done (opening the file selection dialog for instance chances the the current path for that process on Windows) the file may suddenly be accessed in a differnt location than before.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 6 of 6
(3,191 Views)