LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Save file path as indicator after user selects the file

Solved!
Go to solution

Hi, 

 

In my program, the user is prompted to select a file. The file is then read and a series of searches are performed to be able to select a subarray of the initial data. In the case selector, I'd like to be able to save the new subarray that I just found to a new folder path, but using the same file name that the user selected previously. So if the user selected the file from D:\data\SN1322.txt, I want to save the new subarray as C:\ALEIS\calibrations\SN1322.txt. I cant' figure out how to pass the filename and path that the user selected into my case structure to be able to accomplish this.

0 Kudos
Message 1 of 4
(2,929 Views)
Solution
Accepted by topic author krogue

After you're done reading the file, use "close file" (which is best practice) and it will give you the file path which you can input to the strip path function.

Capture.PNG

0 Kudos
Message 2 of 4
(2,880 Views)

Thanks, Gregory. I had that originally but had passed the ref num through the case selector and then put the "close file" on the output side of the case selector (which obviously wasn't helpful.  Smiley Sad  ) 

0 Kudos
Message 3 of 4
(2,867 Views)
Solution
Accepted by topic author krogue

I would recommend to simply use the file dialog and create the other path from the selection.

With the file dialog, you can skip all the code if the dialog gets cancelled without selecting a file.

 

There is no need for lowlevel file IO. All you need is "read delimited spreadsheet", giving you the 2D DBL array directly..

 

Also note that Index array is resizeable. The correct way to get the filename is "strip path". This keeps the extension too.

 

Here's how it could look like....

 

switchFile.png

0 Kudos
Message 4 of 4
(2,822 Views)