NI Home > Community > NI Discussion Forums

LabVIEW

Showing results for 
Search instead for 
Do you mean 
Reply
Active Participant
rickford66
Posts: 229
0 Kudos
Accepted Solution

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.

Active Participant
rickford66
Posts: 229
0 Kudos

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

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.

Active Participant
rickford66
Posts: 229
0 Kudos

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

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.

Active Participant
rickford66
Posts: 229
0 Kudos

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

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.

Active Participant
ben64
Posts: 818
0 Kudos

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


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

Active Participant
rickford66
Posts: 229
0 Kudos

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

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

Active Participant
ben64
Posts: 818
0 Kudos

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

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

Active Participant
rickford66
Posts: 229
0 Kudos

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

Here's what I have....

Active Participant
ben64
Posts: 818
0 Kudos

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

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

Active Participant
rickford66
Posts: 229
0 Kudos

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

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.