LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

absolute path

Solved!
Go to solution
Hi All,
 
I need to save some data in an xml file. First, I need to specify the path where the file will be stored. I tried using a relative path without much success (see error at the end of the file) and I've been unable to find out how to get the absolute path where the vi is located. I want to save the xml file in the current folder where the vi is saved. I want to be able to run the vi even if I move the vi to a different path, without having to change the path string on my block diagram. I tried using Build Path component or String To Path, but they don't seem to do what I want. So, I am looking for a way of getting a string with the current folder path of the vi, which then I can use as an absolute path.
 
Using a Built Path component, I tried using a relative path (like filename.xml for the path string), but I get a strange error with the Write To XML component:
 
Error 1 occured at open file.
Possible reason(s):
LabVIEW:  An input parameter is invalid.
---
NI-488:  Command requires GPIB Controller to be Controller in Charge.
 
When I used a string and a String To Path component, I got this error:
 
Possible reason(s):
LabVIEW:  The path is empty or relative. You must use an absolute path. (and yet, in the help, they advise to use relative paths).
 
Regards,
Nick

Message Edited by Nick_F on 08-22-2006 12:03 AM

Message 1 of 15
(11,508 Views)
I found out myself. I had to add a Default Directory constant to the block diagram, and use it in conjunction with the build path.
0 Kudos
Message 2 of 15
(11,502 Views)

Hi,

 

I was wondering where you attached the default directory to? Base path?

 

Lawrence

0 Kudos
Message 3 of 15
(11,061 Views)
You can generate an absolute path by using Current VI's Path, then stripping it a level and building it back to where the file is you're trying to get at.
Jeff | LabVIEW Software Engineer
0 Kudos
Message 4 of 15
(11,036 Views)

How exactly do you do this? I am getting the same error message when trying to open a file in my default case, writing to it in the next two cases, and then closing it in the last case. (And I'm having problems closing my AWG, but that's fine).

0 Kudos
Message 5 of 15
(10,261 Views)

If you place the attached as a sub-vi, it will provide the folder that the calling vi is stored in. This will work in both the development environment and in an exe.

Is that what you need?

Message 6 of 15
(10,251 Views)

Hehe 🙂 It didn't quite solve my problem, but it solved another problem I've had! I'm not sure how I should have used it to extract the absolute file path and use it further.

 

I solved the problem with my current structure by using local variables instead of global. I hope that wasn't a bad fix? 

0 Kudos
Message 7 of 15
(10,237 Views)

Try putting changing the case statement so that the case for 'Run Time System' only has one strip path, and the default case just wires the path straight through without changing it. This should give you the path of the file rather than the folder it is in.

 

Apologies if this still isn't what you're after... I'm guessing a bit as I can't open your code as I'm on an old version of LabVIEW (8.5)

 

Ian

0 Kudos
Message 8 of 15
(10,233 Views)

Here's the simplest way to return the folder directory path of the current VI; just open the snippet up in LabVIEW to view the code.

 

AbsolutePath.png


Alex Thomas, University of Manchester School of EEE LabVIEW Ambassador (CLAD)

0 Kudos
Message 9 of 15
(10,222 Views)

This would seem relevant at this point, in case anyone gets any surprises:

 

Why Does My Executable Not Work When Using the Current VI's Path Constant?

Message 10 of 15
(10,209 Views)