取消
显示结果 
搜索替代 
您的意思是: 

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 项奖励
1 条消息(共 9 条)
4,314 次查看

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 项奖励
2 条消息(共 9 条)
4,291 次查看

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



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
3 条消息(共 9 条)
4,241 次查看

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!
4 条消息(共 9 条)
4,228 次查看

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 项奖励
5 条消息(共 9 条)
4,204 次查看

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

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 项奖励
6 条消息(共 9 条)
4,192 次查看

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 项奖励
7 条消息(共 9 条)
4,176 次查看

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.



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 项奖励
8 条消息(共 9 条)
4,154 次查看

HI,

 

Refer my suggestion.

Use a Action engine / function global variable.

 

Plz find attached.

 

Regards,

 

Bijay

CLD

0 项奖励
9 条消息(共 9 条)
4,124 次查看