LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Builiding path for folder

When working with projects, there is always a need to either write or read files to disk and at times the folder nesting could be rather deep.

 

I am attaching a VI which i normally use for this and I also have shown two options - onw with BuildPath function and the other with Concatenate String function. Of course the earlier is the preffered one for many reasons.

 

The help i need is : Can this whole thing be made more simpler ? It looks rather too much code - even though it works OK.

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 9
(3,685 Views)

Relevant options:

 

  1. Array of Strings to Path. The Build Path function accepts relative paths on the bottom input, so you should be able to use this.
  2. Use Build Path in a for loop with a shift register to build the path.
  3. Use the Application Directory VI to get the path of the project/EXE.

___________________
Try to take over the world!
0 Kudos
Message 2 of 9
(3,662 Views)

All of your paths really should be relative to the project/executable.  Then you can just use the Application Directory function to get its path, eliminating a large portion of this code (through the case structure).  Then use just 1 Build Path to make your final path and then a Path To String to make your option 2 path.  This eliminates another set of constants and the Concatinate String.

 

So I reduced your VI to this


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 9
(3,612 Views)

I somehow forgot to mention this, even though I did mention that the bottom input takes relative paths, probably because I was focused on the separate elements:

 

PathBuilder-1_BD.png

 

This is more platform independent than Tim's version.


___________________
Try to take over the world!
Message 4 of 9
(3,599 Views)

Great. The solution looks quite simple and neat.

 

I built a small project to check out the concepts and once you unzip the attachment, you will see a simple project. This works fine in design mode but has a problem in EXE mode when I use the Application Directory.

 

I have commented the MAIN vi with all required instructions and issue noted. So is what wrong ?

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 5 of 9
(3,575 Views)

Of particular interest is this document and the highlighted portion ....

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 6 of 9
(3,563 Views)

The section you highlighted is only relevant if you build EXEs in 8.x mode, because the folder structure in EXEs is different now. I don't have time to expand now, but look up the topic of VI paths in executable and when LV includes VIs in EXEs (only if you have a static link to them or if you explicitly include them in the build).


___________________
Try to take over the world!
0 Kudos
Message 7 of 9
(3,547 Views)

Raghunathan wrote:

I built a small project to check out the concepts and once you unzip the attachment, you will see a simple project. This works fine in design mode but has a problem in EXE mode when I use the Application Directory.


The VI you gave us in your original post would have the same issue due to the extra Strip Path.  So we were left to assume you were looking for files outside of your executable.  But since you are looking for VIs inside of your executable, things change.

 

You are doing the right thing in getting the top level VI and using that for the default folder.  As long as you are not using the LabVIEW 8.x executable format, the relative paths for your subVIs stay the same.  The 8.x executable actually has a flat directory structure, so weird things can happen.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 9
(3,525 Views)

HI,

 

Refer my suggestion.

Use a Action engine / function global variable.

 

Plz find attached.

 

Regards,

 

Bijay

CLD

0 Kudos
Message 9 of 9
(3,495 Views)