LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

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

Solved!
Go to solution

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 Kudos
Message 1 of 11
(3,099 Views)

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 Kudos
Message 2 of 11
(3,098 Views)

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 Kudos
Message 3 of 11
(3,095 Views)
Solution
Accepted by 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 Kudos
Message 4 of 11
(3,088 Views)

@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 Kudos
Message 5 of 11
(3,083 Views)

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

0 Kudos
Message 6 of 11
(3,079 Views)

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 Kudos
Message 7 of 11
(3,072 Views)
0 Kudos
Message 8 of 11
(3,069 Views)

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 Kudos
Message 9 of 11
(3,067 Views)

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 Kudos
Message 10 of 11
(3,063 Views)