LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

check a path

Hello,
 
I would like to check if the last element of my path is a .dat or a .txt file.
suggest?
 
thank you
 
L'asticot
0 Kudos
Message 1 of 10
(3,334 Views)
Here is one possibility: convert to a string, then use the attached vi. Similar for .dat.
Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 10
(3,327 Views)

Here's an alternative method:

 

Message Edited by JoeLabView on 06-01-2007 09:24 AM

0 Kudos
Message 3 of 10
(3,322 Views)
In the file I/O-> advanced file functions palette is a VI called get file extension.

Paul
0 Kudos
Message 4 of 10
(3,311 Views)

Thanks Paul..

This is a new vi since LV8.x.

I was doing it in LV7.1.

It's good to know the new tricks.. 🙂

0 Kudos
Message 5 of 10
(3,302 Views)

Unfortunately JoeLabView's version will find the extension anywhere within the filename, so for instance "c:\path\txtcheck.vi"  will show as a .txt file [The comparison is for an pattern and "." will match ANY character]

This selection should all work; including one that will look for either .dat or .txt in one test. Add error in/out as appropriate.

 

 

 

Message Edited by Rod on 06-01-2007 03:13 PM

0 Kudos
Message 6 of 10
(3,302 Views)
Sorry, Joe's test won't match c:\path\txtcheck.vi, but will match c:\path\atxtcheck.vi
 
Rod.
 
0 Kudos
Message 7 of 10
(3,296 Views)
.....or if you want to do something differently depending on the result, you could get the extension, and use the result as a case selector, either "txt", "dat", or Default.
 
 
Rod.
 

Message Edited by Rod on 06-01-2007 03:37 PM

0 Kudos
Message 8 of 10
(3,294 Views)
previous to LabVIEW 8
  1. convert path to string
  2. reverse the string
  3. match pattern [.]+
  4. take the before match output
  5. reverse that string
  6. evaluate the file type

Paul
Message 9 of 10
(3,283 Views)
Very nice Paul!
0 Kudos
Message 10 of 10
(3,267 Views)