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

Program halts on build path, path/file not created.

已解决!
转到解答

I have a small vi that reads from a file on the root drive.  If the file is not there, it creates it.  First off, the vi is halting at build path icon.  This icon is flashing for some reason, but no warning is given.  It's as if there is a break point there, but I didn't put one there, and I don't see one.  Then, when it continues, it fails to create the non-existing path and file.  I've attached the vi in question.  BTW, this is LV7.0.  Thanks.

0 项奖励
1 条消息(共 11 条)
4,541 次查看

I manually created the path and it works fine.  Why, if it's creating the file, doesn't it create the path as well?  I've done this using other paths and it has worked.

0 项奖励
2 条消息(共 11 条)
4,540 次查看

I even tried programmatically creating the folder with "New Directory" but that gives the same error 7.  I have administrative rights on my computer, so it should allow me to create the folder in question.  The OS is Windows XP.

0 项奖励
3 条消息(共 11 条)
4,537 次查看
解答
已被主题作者 rickford66 接受

I figured it out.  It will only create one directory at a time.  I had to convert the directory path into an array and create each directory in sequence.

0 项奖励
4 条消息(共 11 条)
4,530 次查看

@rickford66 wrote:

I figured it out.  It will only create one directory at a time.  I had to convert the directory path into an array and create each directory in sequence.



When you do that take a good care of the first element in the array, it will be C and not C: so if you autoindex a for loop for the case i=0 you need to add the colon to the indexed string.

 

Ben64

0 项奖励
5 条消息(共 11 条)
4,525 次查看

I just put it back together with the Build Path function and it works.

0 项奖励
6 条消息(共 11 条)
4,521 次查看

I just found out that if you use an empty path constant to the base path input of the Build Path function and C to the name or relative path input it will create the base path C:\.

 

In your vi you should use the "Check if File or Folder Exist.vi" (from the File IO -> Advanced File Functions palette) to select the TRUE or FALSE case instead of the error output of the open file function.

 

Ben64

0 项奖励
7 条消息(共 11 条)
4,514 次查看
0 项奖励
8 条消息(共 11 条)
4,511 次查看

I've done something similar but watch the error cluster wire, usually it is used to direct the dataflow (I just wire the path and error cluster wires throught the True case).

 

Ben64

 

Create Directory.png

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

Not sure if your icons are the same as mine, but my File Info function throws an error if the folder does not exist.  Therefore, I don't feed that error through, I just "absorb it" by feeding it to the unbundle cluster.  Probably not the best programming technique, but it silences it.  Also, the New function will return an error if the directory already exists.  The behavior I want is for it to create the folder if it does not exist.  If it exists, then do nothing.

0 项奖励
10 条消息(共 11 条)
4,505 次查看